Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from xgboost import XGBClassifier
- from sklearn.model_selection import train_test_split
- from sklearn.metrics import accuracy_score
- X_train, X_test, y_train, y_test = train_test_split(X, Y, random_state=0)
- # fit model no training data
- model = XGBClassifier()
- model.fit(X_train, y_train)
- # make predictions for test data
- y_pred = model.predict(X_test)
- predictions = [round(value) for value in y_pred]
- # evaluate predictions
- accuracy = accuracy_score(y_test, predictions)
- print("Accuracy: %.2f%%" % (accuracy * 100.0))
Add Comment
Please, Sign In to add comment