from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from joblib import dump # Carregar e dividir o dataset data = load_iris() X = data.data y = data.target X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # Treinando o modelo model = LogisticRegression() model.fit(X_train, y_train) # Salvar o modelo em um arquivo model_filename = "model.pkl" dump(model, model_filename) print("Modelo treinado e salvo!")