我的问题是关于H2O增益/提升表。据我所知,答复率是属于组/组的所有事件的比例。如何获取属于bin 1、bin 2等的数据?我想看看每个组/bin中的关键变量在响应率方面是如何的。。
最好能充分说明增益/升力表中的措施是如何计算的(公式)。
发布于 2018-12-04 17:26:06
增益和升力图的方程可以在以下文件中找到:https://github.com/h2oai/h2o-3/blob/master/h2o-core/src/main/java/hex/GainsLift.java
这表明:
E=活动总数
N=观察次数
G=组数(10组10人,半10名20人)
P=所发生事件的总体比例(P = E/N)
ei = i,i=1,2,.,G组中的事件数
ni =第一组的观察次数
pi =第一组中属于事件的观察所占比例(pi = ei/ni)
组:硬编码为16;如果存在少于16个唯一概率值,则组数将减少到唯一分位数阈值的数目。
累积数据分数= sum_n_i/N
lower_threshold =由分位数桶设置
升力=π/P
cumulative_lift = (Σiei/Σini)/P
response_rate = 100*pi
cumulative_response_rate = 100*Σiei/Σini
capture_rate = 100*ei/E
cumulative_capture_rate = 100*Σiei/E
增益=100*(升力-1)
cumulative_gain =100*(和升-1)
average_response_rate = E/N
下面是一个使用H2O-3 Python的示例演练:
import h2o
import pandas as pd
import numpy as np
from h2o.estimators.gbm import H2OGradientBoostingEstimator
h2o.init()
# import and split the dataset
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 dataset
train, valid = cars.split_frame(ratios=[.7],seed=1234)
# Initialize and train a GBM
cars_gbm = H2OGradientBoostingEstimator(seed = 1234)
cars_gbm.train(x = predictors, y = response, training_frame = train, validation_frame=valid)
# Generate Gains and Lift Table
# documentation on this parameter can be found here:
# http://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/model_categories.html?#h2o.model.H2OBinomialModel.gains_lift
gainslift = cars_gbm.gains_lift(train=False, valid=True, xval=False)表概述
正如预期的那样,我们有16个组,因为这是硬编码的默认行为。
如果我只想要十进制
默认情况下,收益和提升表为您提供了更多,而不仅仅是十进制或通风,这意味着您有更多的灵活性来选择您感兴趣的百分位数。
让我们以我们的十进制为例。在这个例子中,我们看到我们可以从第6行开始,跳过第7行,然后取其余的行来获取我们的十进制文件。
因为增益和提升表返回一个TwoDimTable,所以我们可以使用组号作为选择索引。
# show gains and lift table data type
print('H2O Gains Lift Table is of type: ', type(gainslift))
H2O Gains Lift Table is of type: <class 'h2o.two_dim_table.H2OTwoDimTable'>
# since this table is small and for ease of use let's covert to a pandas dataframe
pandas_gl = gainslift.as_data_frame()
pandas_gl.set_index('group')
gainslift_deciles = pandas_gl.iloc[pd.np.r_[5,7:16], :]
gainslift_deciles如果我只想要呼吸机
这些也可供选择,下面让我们来做。
gainslift_ventiles = pandas_gl.iloc[pd.np.r_[7,9,11,13,15], :]
gainslift_ventileshttps://stackoverflow.com/questions/53545179
复制相似问题