(y_true, y_pred)
| 64 | |
| 65 | |
| 66 | def purity_score(y_true, y_pred): |
| 67 | # compute contingency matrix (also called confusion matrix) |
| 68 | contingency_matrix = metrics.cluster.contingency_matrix(y_true, y_pred) |
| 69 | # return purity |
| 70 | return np.sum(np.amax(contingency_matrix, axis=0)) / np.sum(contingency_matrix) |
| 71 | |
| 72 | # ------------------------------- |
| 73 | # Mixed Eval Function |
no outgoing calls
no test coverage detected