Dimensions question

Hey everyone! How you doing?

I’ve got a pretty basic question, and it is that I can’t really understand why dimensions of the input matrix are (n,m), being m the number of examples and n the number of features, basically meaning that each columns represents a different example and that each rows represents a different feature.

My question comes from working with dataframes that are quite the opposite, since each row is a different example and each column a different feature.

Any help comes much appreciated!

Thanks :slight_smile:

Samples are represented as column based vectors so you can perform the multiplication with the weights matrix. Each element in the column based vector is a feature.

The following next images are taken from this article, I think it may help you to better understand it.



Hey Alberto, thanks for your fast reply!

I understand what you’re saying, and thanks for the article since it was very useful to solidify a little bit more the basic concepts, but I still have a question then, and let me illustrate it with an example this time:

Imagine I have this:

df = pd.DataFrame({"feature_1":np.random.randint(0,2,100),

In this case each row is a different example and each column a different feature (for instance, a (100, 3) shaped matrix).

Now, because we don’t want to process a DataFrame but rather an np.array, once we turn it into one we’re going to have something like this:


The shape on this one is going to be (100, 3) again.

Assuming that I process my data in this way (DataFrame → np.Array where dimensions are (#examples, #features), would I have to transpose the matrix (leaving it shaped like it’s mentioned in the article) to correctly apply the different algorithms? Is that how most people work?

Maybe future exercises clarify this, but I couldn’t really answer my question with the image processing exercise since you basically turn the matrix into one really big array.

I hope this makes my question a little bit more clear, if it’s not tell me and I’ll rephrase it.

Thanks! :smiley:

Yes, you would need to transpose the matrix, not really a problem though :slight_smile:

1 Like

Thank you so much for your replies!