Skip to content

Instantly share code, notes, and snippets.

@QuantumDamage
Created April 15, 2017 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QuantumDamage/09703d4980deab88a68672d34c600808 to your computer and use it in GitHub Desktop.
Save QuantumDamage/09703d4980deab88a68672d34c600808 to your computer and use it in GitHub Desktop.
import numpy as np
from sklearn.model_selection import train_test_split
from xgboost import XGBClassifier
# NOTE: Make sure that the class is labeled 'class' in the data file
tpot_data = np.recfromcsv('PATH/TO/DATA/FILE', delimiter='COLUMN_SEPARATOR', dtype=np.float64)
features = np.delete(tpot_data.view(np.float64).reshape(tpot_data.size, -1), tpot_data.dtype.names.index('class'), axis=1)
training_features, testing_features, training_classes, testing_classes = \
train_test_split(features, tpot_data['class'], random_state=42)
exported_pipeline = XGBClassifier(learning_rate=0.01, max_depth=6, min_child_weight=2, n_estimators=100, nthread=1, subsample=0.55)
exported_pipeline.fit(training_features, training_classes)
results = exported_pipeline.predict(testing_features)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment