from sklearn.datasets import load_iris
from sklearn.model_selection import StratifiedKFold, cross_val_score
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
X, y = load_iris(return_X_y=True)
cv = StratifiedKFold(n_splits=4, shuffle=True, random_state=42)
modelos = {"logística": make_pipeline(StandardScaler(), LogisticRegression(max_iter=1000)), "floresta": RandomForestClassifier(n_estimators=60, max_depth=4, random_state=42)}
for nome, modelo in modelos.items():
    resultados = cross_val_score(modelo, X, y, cv=cv, scoring="f1_macro")
    print(nome, "média:", round(resultados.mean(), 3), "dispersão:", round(resultados.std(), 3))
