The shape of X in dataset

A lot of times, the way we have our dataset in work, or sklearn or other library is shaped as num_of_samples x num_of_features. However, Prof. Ng in Logistic Reg Vectorization video talks about it as num_of_features x num_of_samples. Does that mean we have to change the shape of X_train and X_test every time we fit it? Does the sklearn do it by itself?

There is no standardization on the orientation. Some datasets will be one way, others may be different.

You may have to transpose a matrix before you can use it.

sklearn does not do this automatically.

Adding on, the order of multiplication of matrices may change depending on the shape of the original matrix. Dimension matching/checking is the deciding factor for the order of multiplication.

1 Like