Indexing features and training examples

Hello
I’ve noticed that throughout the lectures we are using

  1. m is the number of training examples;
  2. index i from 1 to m to enumerate training examples;
  3. n is the number of features and
  4. index j from 1 to n to enumerate features.

However, in practice labs indexing is reversed: i from 1 to m is used for features, and j from 1 to n is used for training examples.

I am doing the Anomaly detection lab right now, but I’ve seen this in previous labs too - and it confused me every time I see it in a lab. I think using indexing consistently between lectures and labs would make this a little easier. Or am I misreading/misunderstand this completely?
Thank you!

Hello @Svetlana_Verthein

Perfect understanding.

One small difference in the lab is that the indices go from 0 to m - 1 or from 0 to n - 1. Computer counts from 0, human usually counts from 1.

I am also just reading the anomaly detection lab, but m still stands for samples. For example,

Can you give some screenshots that use m or n differently, but without showing any assignment solution? (because we can’t share learners’ own work here).

Cheers,
Raymond

sorry, you are correct. In the lab m is still samples, and n is still features, it’s just the i and the j are reversed - correct?

In that lab, yes, we used j for samples, and sometimes in the lecture we used i. I can’t say they are always reversed because otherwise I will have to check through the labs one by one.

While we usually use m for samples and n for features, it is, at the end of the day, our job to check the meaning of symbols, because there is no universal standard. :wink:

Cheers,
Raymond

1 Like

Sounds good. I did run into this issue before (I also posted a question here on the forums). My mistake was - I see index i - and I imagine it to be the i-th training example, not the i-th feature, and from there all my code is wrong :open_mouth:
I will pay closer attention in the labs.
Thank you for quick replies, Raymond!

You are welcome, @Svetlana_Verthein!

Raymond