Htm.core -- am I getting prediction density correctly?

Hi Guys!

My goal: to measure prediction density in TM within htm.core.
My question: am I doing it right? Here’s my current code:

I’m doing this in order to measure precision in TM.

I know I could technically achieve this by reporting either:

  • number of predicted cells

  • sparsity of predicted cells relative to the whole TM region

But I want to normalize it to a pred_count (how many predictions were made), so non-HTM people can intuitively understand it.

I though to achieved this with:
n_pred_cells / n_winner_cells

I assumed that n_winner_cell would be constant, but I found it sometimes varies:
Screen Shot 2022-01-05 at 6.16.47 PM

Does this look like a valid approach to you?

Thanks!

1 Like

When a minicolumn activates: the TM makes sure that at least one of the cells in the minicolumn is a winner cell. If there were no predictive cells it picks an arbitrary winner. If there are predictive cells, then all of the predicted cells in the mini-column are winners.


So if I understand correctly, you want to tell the user “how many things are predicted”.

  • If this number is zero, then you’ve hit an anomaly.
  • If this number is one, then TM is predicting exactly one thing will happen.
  • If this number is two, then TM is predicting that one of two different things could happen.

The minimum number of cells that the TM will activate to represent a thing is the number of active minicolumns.

The equation to try is:
n_predicted_things = n_pred_cells / n_active_minicolumns

I hope this helps

3 Likes

Thanks @dmac!

Yes you make perfect sense.
I hadn’t considered your point about winnerCells including predicted cells – enabling >1 per column.

I’ve since updated the code to use equivalent of n_active_minicolumns as denominator, like you show.

I name it n_cols_per_pred, in case the person reading the code is unfamiliar w/HTM terms. I get it by multiplying sp params columnCount & localAreaDensity - since their product is ~72.

I think I have it right now – but all ears for any corrections/improvements!

Thanks again!

2 Likes