Last active
July 27, 2017 23:41
-
-
Save ybenjo/29dc5b81a9f4ee79074b4fd979596e0e to your computer and use it in GitHub Desktop.
xgboost bug (handling nested array)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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