Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New confusion natrix #392

Merged
merged 4 commits into from
Aug 12, 2024
Merged

New confusion natrix #392

merged 4 commits into from
Aug 12, 2024

Conversation

NoaShapira8
Copy link
Collaborator

fixing bugs


if has_multiple_max:
LOG_INFO(f"Worker {worker_name} has at least one sample with multiple predicted labels")
#max_column_predict_index = is_max.apply(lambda row: list(row[row].index), axis=1).tolist() # Generate a list of lists' each sublist has the index of the maximum value in the row
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line is commented out. Decide to remove or to add it with condition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it.

max_column_predict_index =[[int(predict_label) - num_of_labels for predict_label in prdict_indexes_sublist] for prdict_indexes_sublist in max_column_predict_index] # fix the index to original labels index
max_column_labels_index = df_worker_labels.iloc[:, :num_of_labels].idxmax(axis=1).tolist() # Get the index of the maximum actual value in each row

else: # No sample with multiple predicted labels
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean No sample?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that means that in each sample there is only 1 predicted label

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why no sample.

max_column_labels_index = df_worker_labels.iloc[:, :num_of_labels].idxmax(axis=1).tolist() # Get the index of the maximum actual value in each row

else: # No sample with multiple predicted labels
# Take 2 list from the df, one for the actual labels and one for the predict labels to build the confusion matrix
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - lists

Copy link
Collaborator Author

@NoaShapira8 NoaShapira8 Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

class_predict_list = [1 if label_num == class_index else 0 for label_num in max_column_predict_index] # 1 if the label is belong to the class, 0 otherwise
confusion_matrix = metrics.confusion_matrix(class_actual_list, class_predict_list)
labels = [0, 1]
confusion_matrix = metrics.confusion_matrix(class_actual_list, class_predict_list, labels=labels)
#confusion_matrix_np = confusion_matrix.to_numpy()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decide - Remove if not needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it.

max_column_predict_index =[[int(predict_label) - num_of_labels for predict_label in prdict_indexes_sublist] for prdict_indexes_sublist in max_column_predict_index] # fix the index to original labels index
max_column_labels_index = df_worker_labels.iloc[:, :num_of_labels].idxmax(axis=1).tolist() # Get the index of the maximum actual value in each row

else: # No sample with multiple predicted labels
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why no sample.

@leondavi leondavi merged commit cdbb932 into master Aug 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants