scikit-learn - 회귀 | Randomforest, XGBoost

안동균·2024년 11월 13일

분류모델인 Randomforest, XGBoost의 회귀 예제

Randomforest

from sklearn.ensemble import RandomForestRegressor

model = RandomForestRegressor()
model.fit(x_train, y_train)
pred = model.predict(x_test)
mean_squared_error(y_test, pred)

XGBoost

from xgboost import XGBRegressor

model = XGBRegressor()
model.fit(x_train, y_train)
pred = model.predict(x_test)
mean_squared_error(y_test, pred)

0개의 댓글