import h2o h2o.init() from h2o.estimators.gbm import H2OGradientBoostingEstimator iris_data_path = h2o.system_file("iris.csv") # load demonstration data iris_df = h2o.import_file(path=iris_data_path) iris_df.describe() gbm_regressor = H2OGradientBoostingEstimator(distribution="gaussian", ntrees=10, max_depth=3, min_rows=2, learn_rate="0.2") gbm_regressor.train(x=range(1,iris_df.ncol), y=0, training_frame=iris_df) gbm_regressor gbm_classifier = H2OGradientBoostingEstimator(distribution="multinomial", ntrees=10, max_depth=3, min_rows=2, learn_rate="0.2") gbm_classifier.train(x=range(0,iris_df.ncol-1), y=iris_df.ncol-1, training_frame=iris_df) gbm_classifier from h2o.estimators.glm import H2OGeneralizedLinearEstimator prostate_data_path = h2o.system_file("prostate.csv") prostate_df = h2o.import_file(path=prostate_data_path) prostate_df["RACE"] = prostate_df["RACE"].asfactor() prostate_df.describe() glm_classifier = H2OGeneralizedLinearEstimator(family="binomial", nfolds=10, alpha=0.5) glm_classifier.train(x=["AGE","RACE","PSA","DCAPS"],y="CAPSULE", training_frame=prostate_df) glm_classifier from h2o.estimators.kmeans import H2OKMeansEstimator cluster_estimator = H2OKMeansEstimator(k=3) cluster_estimator.train(x=[0,1,2,3], training_frame=iris_df) cluster_estimator
import h2o h2o.init() path = h2o.system_file("prostate.csv") h2o_df = h2o.import_file(path) h2o_df['CAPSULE'] = h2o_df['CAPSULE'].asfactor() binomial_fit = h2o.glm(y = "CAPSULE", x = ["AGE", "RACE", "PSA", "GLEASON"], training_frame = h2o_df, family = "binomial")
import h2o h2o.init() path = h2o.system_file("prostate.csv") h2o_df = h2o.import_file(path) gaussian_fit = h2o.glm(y = "VOL", x = ["AGE", "RACE", "PSA", "GLEASON"], training_frame = h2o_df, family = "gaussian")