Skip to content

Instantly share code, notes, and snippets.

@gabrielziegler3
Created April 20, 2019 03:45
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 gabrielziegler3/258e54489699445a9309cdcb1eb0345e to your computer and use it in GitHub Desktop.
Save gabrielziegler3/258e54489699445a9309cdcb1eb0345e to your computer and use it in GitHub Desktop.
# META CODE
from sklearn.multiclass import OneVsRestClassifier
from xgboost import XGBClassifier
from sklearn.preprocessing import MultiLabelBinarizer
clf = OneVsRestClassifier(XGBClassifier(n_jobs=-1, max_depth=4))
# You may need to use MultiLabelBinarizer to encode your variables from arrays [[x, y, z]] to a multilabel
# format before training.
mlb = MultiLabelBinarizer()
y = mlb.fit_transform(y)
clf.fit(X, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment