bagging boosting
from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split # Load the Iris dataset iris = load_iris() X, y = iris.data, iris.target # Split the data into training and testing sets X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) # Initialize a Random Forest Classifier rf = RandomForestClassifier(n_estimators=10, random_state=42) # Train the Random Forest Classifier rf.fit(X_train, y_train) # Evaluate the performance of the Random Forest Classifier print("Accuracy:", rf.score(X_test, y_test))