Python source code: gradient_boosting_regression.py
from sklearn import ensemblefrom sklearn.metrics import mean_squared_error # Fit regression model params = {‘n_estimators‘: 500, ‘max_depth‘: 4, ‘min_samples_split‘: 1, ‘learning_rate‘: 0.01, ‘loss‘: ‘ls‘} clf = ensemble.GradientBoostingRegressor(**params) clf.fit(X_train, y_train) mse = mean_squared_error(y_test, clf.predict(X_test)) print("MSE: %.4f" % mse)
时间: 2024-10-25 16:32:32