from sklearn.ensemble import RandomForestClassifier
# create model
model = RandomForestClassifier()
# train model
model.fit(X_train, y_train)
# predict on test set
y_pred = model.predict(X_test)
# evaluate model
from sklearn.metrics import accuracy_score
print("Accuracy:", accuracy_score(y_test, y_pred))
pythonCopy code
from sklearn.ensemble import RandomForestClassifier
# 모델 생성
model = RandomForestClassifier()
# 모델 훈련
model.fit(X_train, y_train)
pythonCopy code
# 테스트 세트에서 예측
y_pred = model.predict(X_test)
# 모델 평가
from sklearn.metrics import accuracy_score
print("정확도:", accuracy_score(y_test, y_pred))