add code for multioutput regression#576
Open
AaronDavidSchneider wants to merge 3 commits intoBayesWitnesses:masterfrom
Open
add code for multioutput regression#576AaronDavidSchneider wants to merge 3 commits intoBayesWitnesses:masterfrom
AaronDavidSchneider wants to merge 3 commits intoBayesWitnesses:masterfrom
Conversation
Author
|
I hereby also add some tests. And here is another simple way to verify that it works: n_targets = 3
n_features = 3
n_test = 20
n_train = 20
X, y = datasets.make_regression(n_targets=n_targets, n_features=n_features, n_samples=n_train, random_state=1)
multi_class_model_params = {
'n_estimators': 3,
'max_depth': 2
}
model = XGBRegressor(**multi_class_model_params).fit(X, y)
code = m2cgen.export_to_python(model, function_name=f'predict')
with open('test_file.py', 'w') as f:
f.write(code)
from test_file import predict
input = np.random.random((n_test, n_targets))
closenes = []
for i, input_i in enumerate(input):
hardcoded = predict(input_i)
apipred = model.predict(input_i.reshape((1, n_features)))
closenes.append(np.allclose(apipred, hardcoded))
print(f'All close: {np.all(closenes)}, fraction of close: {np.sum(closenes)/n_test}')Which works well for me. I also ran the Unfortunately, the docker command also fails on my machine, which does not seem to be caused by my changes but rather by the docker build command. I hope that the CI will give more insight! |
Author
|
Kindly pinging @izeigerman and @StrikerRUS |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the option for multioutput regression in XGBoost. This could work for other booster classes as well. However, there is no general attribute that informs about the number of targets. Thats why this solution is restricted to XGBoost.
Closes #559