Python H2O蟒蛇。得不到ACU

Python H2O蟒蛇。得不到ACU,python,h2o,Python,H2o,我正在学习h2o模型预测。当我这样做时: data_frame = h2o.H2OFrame(python_obj=data[1:], column_names=data[0]) data_train, data_valid, data_test = data_frame.split_frame(ratios= config.trainer_analizer_ratios, seed=config.trainer_analizer_seed) # H2OGeneralizedLinearEst

我正在学习h2o模型预测。当我这样做时:

data_frame = h2o.H2OFrame(python_obj=data[1:], column_names=data[0])
data_train, data_valid, data_test = data_frame.split_frame(ratios= config.trainer_analizer_ratios, seed=config.trainer_analizer_seed)

# H2OGeneralizedLinearEstimator
allLog += "/n Starting H2OGeneralizedLinearEstimator"
model_gle = h2o.estimators.H2OGeneralizedLinearEstimator()
model_gle.train(x=predictors, y=response, training_frame= data_train, validation_frame= data_valid)
print(model_gle)
perf_gle = model_gle.model_performance(test_data= data_test)
print("GBM Precision:",perf_gle)
我得到以下输出

** Reported on test data. **

MSE: 494.25950875189955
RMSE: 22.23194792976764
MAE: 17.380709221249717
RMSLE: 1.217426465475652
R^2: 0.04331665117221439
Mean Residual Deviance: 494.25950875189955
Null degrees of freedom: 1177
Residual degrees of freedom: 1174
Null deviance: 608812.1064795277
Residual deviance: 582237.7013097376
AIC: 10660.224689554776

为什么我不获取
ACU
指标?我需要它来给不同的模型打分。

GLM算法认为你在解决回归问题。您需要指定您正在解决分类问题。您可以使用family参数(请参见示例)执行此操作,并且可能需要使用
asfactor()
方法将目标设置为type
enum

为方便起见,以下是链接指向的示例代码段:

import h2o
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
h2o.init()

# import the cars dataset:
# this dataset is used to classify whether or not a car is economical based on
# the car's displacement, power, weight, and acceleration, and the year it was made
cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")

# convert response column to a factor
cars["economy_20mpg"] = cars["economy_20mpg"].asfactor()

# set the predictor names and the response column name
predictors = ["displacement","power","weight","acceleration","year"]
response = "economy_20mpg"

# split into train and validation sets
train, valid = cars.split_frame(ratios = [.8])

# try using the `family` parameter:
# Initialize and train a GLM
cars_glm = H2OGeneralizedLinearEstimator(family = 'binomial')
cars_glm.train(x = predictors, y = response, training_frame = train, validation_frame = valid)

# print the auc for the validation data
cars_glm.auc(valid = True)

不行。如果我将响应作为因子,则会出现以下错误:
ERRR on字段:\u响应:回归需要数字响应,get category
您是说上面的代码片段对您不起作用,还是说您的代码不起作用。除了将目标转换为类别之外,还需要使用
DLINEARestimator(family='binominal')
指定您的
family=binominal
。请注意,您的错误是,您的算法仍然认为您正在处理回归问题,但您已经成功地将目标转换为类型category。