f1 score
import numpy as np from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.metrics import f1_score #Split the data into training and testing sets X_train, X_test, y_train, y_test = train_test_split(df, y, test_size=0.1, random_state=42) #Train a logistic regression model model = LogisticRegression(max_iter=1000) model.fit(X_train, y_train) #Make predictions y_pred = model.predict(X_test) # Metric f1 = f1_score(y_test, y_pred,average='micro') print(f1)