bagging and boosting
from sklearn.datasets import load_breast_cancer from sklearn.ensemble import AdaBoostClassifier from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split #Load the Breast Cancer Wisconsin dataset cancer = load_breast_cancer() X, y = cancer.data, cancer.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 Decision Tree Classifier dt = DecisionTreeClassifier(random_state=42) #Initialize an AdaBoost Classifier boosting = AdaBoostClassifier(dt, n_estimators=50, random_state=42) #Train the AdaBoost Classifier boosting.fit(X_train, y_train) #Evaluate the performance of the AdaBoost Classifier print("Accuracy:", boosting.score(X_test, y_test))