Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create examples for the Multinomial Models section in the Python documentation #8905

Closed
exalate-issue-sync bot opened this issue May 12, 2023 · 2 comments
Assignees

Comments

@exalate-issue-sync
Copy link

The http://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/model_categories.html#module-h2o.model.multinomial section in the Python documentation is missing examples.

The source file is located at h2o-3/h2o-py/model/multinomial.py

Multinomial examples are available in this https://github.com/h2oai/h2o-3/blob/master/h2o-py/tests/testdir_misc/pyunit_metric_accessors.py#L414

Note that the following in the test is incorrect (line 423):

{code}
gbm.distribution="multinomial"
{code}

Replace that line with the following to build the model:

{code}
gbm = H2OGradientBoostingEstimator(nfolds=3, distribution=distribution)
{code}

The examples use the cars dataset:
cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")

@exalate-issue-sync
Copy link
Author

Angela Bartz commented: You can use the following example for the confusion matrix. This is a little different than the binomial example:

{code}
import h2o
h2o.init()
from h2o.estimators.gbm import H2OGradientBoostingEstimator

cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
cars["cylinders"] = cars["cylinders"].asfactor()
r = cars[0].runif()
train = cars[r > .2]
valid = cars[r <= .2]
response_col = "cylinders"
distribution = "multinomial"
predictors = ["displacement","power","weight","acceleration","year"]

gbm = H2OGradientBoostingEstimator(nfolds=3, distribution=distribution)
gbm.train(x=predictors,y=response_col, training_frame=train, validation_frame=valid)
confusion_matrix = gbm.confusion_matrix(train)
{code}

@h2o-ops
Copy link
Collaborator

h2o-ops commented May 14, 2023

JIRA Issue Migration Info

Jira Issue: PUBDEV-6728
Assignee: hannah.tillman
Reporter: Angela Bartz
State: Resolved
Fix Version: 3.28.0.1
Attachments: N/A
Development PRs: Available

Linked PRs from JIRA

#3762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants