You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following error with avg_score multilabel strategy -
File "C:\Users\localuserSKSG\anaconda3\envs\alenv\lib\site-packages\modAL\models\base.py", line 175, in query
query_result, query_metrics = self.query_strategy( File "C:\Users\localuserSKSG\anaconda3\envs\alenv\lib\site-packages\modAL\multilabel.py",
line 258, in avg_score classwise_scores = classwise_confidence*(classwise_predictions-1/2)
ValueError: operands could not be broadcast together with shapes (26872,2,3) (26872,3)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "avg-score.py", line 264, in
query_index, query_instance = learner.query(X_pool_np, n_instances=n_instances)
File "C:\Users\localuserSKSG\anaconda3\envs\alenv\lib\site-packages\modAL\models\base.py", line 180, in query
query_result = self.query_strategy( File "C:\Users\localuserSKSG\anaconda3\envs\alenv\lib\site-packages\modAL\multilabel.py", line 258, in
avg_score classwise_scores = classwise_confidence*(classwise_predictions-1/2) ValueError: operands could not be broadcast together with shapes (26872,2,3) (26872,3)
We do not see this error with avg_confidence. Clearly this is because of these lines of code in avg_score which are not present in avg_confidence-
The error message indicates that the classwise_confidence and classwise_predictions - 1/2 arrays have incompatible shapes and cannot be broadcast together.
Understanding the Issue:
• classwise_confidence has shape (26872, 2, 3).
• classwise_predictions - 1/2 has shape (26872, 3).
• Since they do not match, NumPy cannot perform element-wise multiplication.
Possible Fix:
1. Check classifier.predict(X_pool) Output:
• The shape mismatch suggests that classifier.predict(X_pool) returns (26872, 3), while classwise_confidence has an extra dimension (26872, 2, 3).
• Ensure that classifier.predict(X_pool) returns the expected number of class probabilities. If it is returning a (26872, 3), confirm why classwise_confidence has (26872, 2, 3).
Activity
naveedyassin commentedon Mar 22, 2025
The error message indicates that the classwise_confidence and classwise_predictions - 1/2 arrays have incompatible shapes and cannot be broadcast together.
Understanding the Issue:
• classwise_confidence has shape (26872, 2, 3).
• classwise_predictions - 1/2 has shape (26872, 3).
• Since they do not match, NumPy cannot perform element-wise multiplication.
Possible Fix:
1. Check classifier.predict(X_pool) Output:
• The shape mismatch suggests that classifier.predict(X_pool) returns (26872, 3), while classwise_confidence has an extra dimension (26872, 2, 3).
• Ensure that classifier.predict(X_pool) returns the expected number of class probabilities. If it is returning a (26872, 3), confirm why classwise_confidence has (26872, 2, 3).