Skip to content

Instantly share code, notes, and snippets.

@a-agmon
Last active August 18, 2019 14:31
Show Gist options
  • Save a-agmon/3e56627c06e7c808bab5edf7693c096b to your computer and use it in GitHub Desktop.
Save a-agmon/3e56627c06e7c808bab5edf7693c096b to your computer and use it in GitHub Desktop.
#fit the model
from xgboost import XGBClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
model = XGBClassifier()
model.fit(x_train, y_train)
accuracy = accuracy_score(y_test, predictions)
print("Accuracy: %.2f%%" % (accuracy * 100.0))
#evaluate the model
import sklearn.metrics as metrics
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))
cm = confusion_matrix(y_test, y_pred)
print(cm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment