Skip to content

Commit

Permalink
review-suggestioons
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunyogeshwaran committed Sep 27, 2024
1 parent 503cf3f commit 72904b5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions h2o-bindings/bin/custom/python/gen_rulefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@ def predict_rules(self, frame, rule_ids):
>>> import h2o
>>> h2o.init()
>>> from h2o.estimators import H2ORuleFitEstimator
>>> f = "https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv"
>>> df = h2o.import_file(path=f, col_types={'pclass': "enum", 'survived': "enum"})
>>> x = ["age", "sibsp", "parch", "fare", "sex", "pclass"]
>>> y = "survived"
>>> rfit = H2ORuleFitEstimator(max_rule_length=10,
... max_num_rules=100,
... seed=1)
>>> rfit.train(training_frame=df, x=x, y=y)
>>> predictions = rfit.predict(test)
>>> print("Predictions:\n", predictions)
>>> f = "https://s3.amazonaws.com/h2o-public-test-data/smalldata/iris/iris_train.csv"
>>> df = h2o.import_file(path=f, col_types={'species': "enum"})
>>> x = df.columns
>>> y = "species"
>>> x.remove(y)
>>> train, test = df.split_frame(ratios=[.8], seed=1234)
>>> rfit = H2ORuleFitEstimator(min_rule_length=4,
... max_rule_length=5,
... max_num_rules=3,
... seed=1234,
... model_type="rules")
>>> rfit.train(training_frame=train, x=x, y=y, validation_frame=test)
>>> print(rfit.predict_rules(train, ['M0T38N5_Iris-virginica']))
"""
from h2o.frame import H2OFrame
from h2o.utils.typechecks import assert_is_type
Expand Down

0 comments on commit 72904b5

Please sign in to comment.