Skip to content

Instantly share code, notes, and snippets.

@ybenjo
Last active July 27, 2017 23:41
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 ybenjo/29dc5b81a9f4ee79074b4fd979596e0e to your computer and use it in GitHub Desktop.
Save ybenjo/29dc5b81a9f4ee79074b4fd979596e0e to your computer and use it in GitHub Desktop.
xgboost bug (handling nested array)
# Version: 0.6a2
from xgboost import XGBRegressor
model = XGBRegressor(seed = 1)
# XOR pattern + [0, 0, 0]
train_data = [
[1, 0] + [0] * 3,
[0, 1] + [0] * 3,
[1, 1] + [0] * 3,
[0, 0] + [0] * 3,
]
train_y = [1, 1, 0, 0]
model.fit(train_data, train_y)
# XOR Pattern + [1, 1, 1]
test_data = [
[0, 0] + [1] * 3
]
model.predict(test_data)
# ValueError: feature_names mismatch: ['f0', 'f1'] ['f0', 'f1', 'f2', 'f3', 'f4']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment