Compute the top-k accuracy score

python datascience classification
Jul 17, 202309:18 PM255 views
0

Problem

Let's say we are learning a classifier for the `Iris` dataset. ```python from sklearn.datasets import load_iris X, y_true = load_iris(return_X_y=True, as_frame=True) ``` The classifier is a `RandomForestClassifier` learned as follows. ```python from sklearn.ensemble import RandomForestClassifier model = RandomForestClassifier(n_estimators=2) model.fit(X, y_true) ``` Compute the top-k accuracy measure for k=1 and k=2.
Menu