def main(model_path): h2o.init(nthreads=-1, max_mem_size=16) serve(model_path)
from h2o import h2o h2o.init() # example adapted from http://h2o-release.s3.amazonaws.com/h2o-dev/rel-shannon/2/docs-website/h2o-py/docs/h2o.html#models fr = h2o.import_file( path= "https://raw.githubusercontent.com/h2oai/h2o-2/master/smalldata/logreg/prostate.csv" ) r = fr[0].runif() train = fr[r < 0.70] test = fr[r >= 0.70] train["CAPSULE"] = train["CAPSULE"].asfactor() test["CAPSULE"] = test["CAPSULE"].asfactor() m = h2o.H2OGeneralizedLinearEstimator(family='binomial', alpha=[0.5]) m.train(x=["AGE", "RACE", "PSA", "VOL", "GLEASON"], y="CAPSULE", training_frame=train) m.show()
def __init__(self, ip, port): self.ip = ip self.port = port # initialize the http connection, needed for the communication via REST endpoints h2o.init(ip=ip,port=port) self.scala_session_id = H2OContext.init_scala_int_session()
import pandas as pd from h2o import h2o # Removing existing data from H2O Cluster h2o.init(ip="localhost", port=54321) h2o.remove_all() # Loading HR Analytics Data from CSV File full_data_frame = h2o.H2OFrame( pd.read_csv("dataset/HR_comma_sep.csv", index_col=None, header=0)) # Defining categorical features feature_columns = [ 'left', 'Work_accident', 'promotion_last_5years', 'department' ] # Defining continuous features continuous_feature_columns = [ 'satisfaction_level', 'last_evaluation', 'number_project', 'average_montly_hours', 'time_spend_company', 'salary' ] training_data_frame, test_data_frame = full_data_frame.split_frame(ratios=[.8]) training_data_frame[feature_columns] = training_data_frame[ feature_columns].asfactor() test_data_frame[feature_columns] = test_data_frame[feature_columns].asfactor() print(training_data_frame[0, :]) print(test_data_frame[0, :])
def __init__(self, ip, port, initialize = True): self.ip = ip self.port = port # initialize the http connection, needed for the communication via REST endpoints if initialize: h2o.init(ip=ip, port=port)