import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier import joblib # Load dataset data = pd.read_csv('Iris.csv') data.drop(columns=['Id'], inplace=True) # Prepare features and target X = data.drop(columns=['Species']) y = data['Species'] # Split the data X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # Train the model model = RandomForestClassifier(n_estimators=100, random_state=42) model.fit(X_train, y_train) # Save the model joblib.dump(model, 'model.pkl')