Describe the bug
LocalClassifierPerParentNode.predict_proba() and LocalClassifierPerNode.predict_proba() return zero probabilities for leaves at intermediary levels.
To Reproduce
Here is an example:
from sklearn import svm
from hiclass import LocalClassifierPerParentNode
train_x = np.array([[0], [1], [2]])
train_y = np.array([[0], [1, 1], [1, 2]], dtype=object)
model = svm.SVC(probability=True)
classifier = LocalClassifierPerParentNode(model, return_all_probabilities=False)
classifier.fit(train_x, train_y)
print(classifier.predict(train_x))
print(classifier.classes_)
print(classifier.predict_proba(train_x))
predict_proba() returns the probabilities at the last level, so the returned probability of the label "0" is always zero.
Note that a workaround is to "left-pad" the shorter path instead of letting the default behavior of right-padding with an empty string:
train_y = np.array([[0, 0], [1, 1], [1, 2]], dtype=object)
gives the right probabilities.
Expected behavior
All leaves should be treated by predict_proba() as if they were on the last level of the hierarchy.
The result of predict_proba() with parameter return_all_probabilities=True is unclear, but a consistent behavior may be to bring the nodes of shorter paths down the hierarchy instead of letting them up.
Version
hiclass = 5.0.4
Describe the bug
LocalClassifierPerParentNode.predict_proba() and LocalClassifierPerNode.predict_proba() return zero probabilities for leaves at intermediary levels.
To Reproduce
Here is an example:
predict_proba() returns the probabilities at the last level, so the returned probability of the label "0" is always zero.
Note that a workaround is to "left-pad" the shorter path instead of letting the default behavior of right-padding with an empty string:
train_y = np.array([[0, 0], [1, 1], [1, 2]], dtype=object)gives the right probabilities.
Expected behavior
All leaves should be treated by predict_proba() as if they were on the last level of the hierarchy.
The result of predict_proba() with parameter
return_all_probabilities=Trueis unclear, but a consistent behavior may be to bring the nodes of shorter paths down the hierarchy instead of letting them up.Version
hiclass = 5.0.4