Regarding the code for A Priori
jayahm opened this issue · 2 comments
I went through the code (the class) your A Priori
https://github.com/scikit-learn-contrib/DESlb/blob/master/deslib/dcs/a_priori.py
On line 192,
scores_target_class = self.dsel_scores_[neighbors, :,
self.DSEL_target_[neighbors]]
I quite don't understand on self.DSEL_target_[neighbors]
From my understanding, it is the index of the target class of the sample in the region of competence.
self.DSEL_target_[neighbors]
will produce an array of shape (n_samples), where n_samples = the size of the region of competence
self.dsel_scores_
is an array of shape (n_samples, n_classifiers, n_classes)
Why the shape of self.DSEL_target_[neighbors]
is not the same as the shape of n_classes
?
self.dsel_scores_[neighbors, :, self.DSEL_target_[neighbors]]
self.dsel_scores_[n_samples, n_classifiers, n_classes]
No, it is not the shape of n_classes, the result array from self.DSEL_target_[neighbors]
operation is the same shape as the neighbors array. However, each element in the result array is a value between 0 to n_classes -1. This value is then used to index the desired class.
In order to understand more about NumPy advanced indexing, I really recommend you to check this tutorial: https://numpy.org/doc/stable/reference/arrays.indexing.html
I would also recommend you to evaluate each expression individually using a debugger (you can use Pycharm for that) so you can get more familiar with this type of array indexing.
I see. It was my misunderstanding of how NumPy's slicing works.
Thank you.