sklift.models.SoloModel

class sklift.models.models.SoloModel(estimator, method='dummy')[source]

也称为治疗虚拟方法,或单一模型方法,或S-学习者。

在整个数据集上拟合单独模型,将‘treatment’作为附加特征。

测试样本中的每个对象都会被评分两次:一次是通信标志等于1,另一次是通信标志等于0。 通过减去每个观察值的概率,我们得到了提升值。

返回每个示例的预测差异。

了解更多,请参阅用户指南

Parameters
  • estimator (实现 'fit' 的估计器对象) – 用于拟合数据的对象。

  • method (string, ’dummy’ or ’treatment_interaction’, default='dummy') –

    指定方法:

    • 'dummy':

      单一模型;

    • 'treatment_interaction':

      包含治疗交互的单一模型。

trmnt_preds_

治疗时对样本的估计器预测。

Type

类数组, 形状 (n_samples, )

ctrl_preds_

控制时对样本的估计器预测。

Type

类数组, 形状 (n_samples, )

示例:

# import approach
from sklift.models import SoloModel
# import any estimator adheres to scikit-learn conventions
from catboost import CatBoostClassifier


sm = SoloModel(CatBoostClassifier(verbose=100, random_state=777))  # define approach
sm = sm.fit(X_train, y_train, treat_train, estimator_fit_params={{'plot': True})  # fit the model
uplift_sm = sm.predict(X_val)  # predict uplift

参考文献

Lo, Victor. (2002). 真实提升模型 - 一种新颖的数据挖掘方法用于数据库营销中的响应建模。SIGKDD探索。4. 78-86.

另请参阅

其他方法:

其他:

fit(X, y, treatment, estimator_fit_params=None)[source]

根据给定的训练数据拟合模型。

对于每个测试示例,分别使用第一个和第二个模型对新数据集进行预测。 然后计算这些预测之间的差异作为提升值。

返回每个示例的预测差异。

Parameters
  • X (数组形式, 形状 (n_samples, n_features)) – 训练向量,其中 n_samples 是样本数量,n_features 是特征数量。

  • y (数组形式, 形状 (n_samples,)) – 相对于X的二元目标向量。

  • treatment (array-like, shape (n_samples,)) – 相对于X的二元处理向量。

  • estimator_fit_params (dict, optional) – 传递给估计器fit方法的参数。

Returns

self

Return type

对象

predict(X)[source]

对X中的样本进行提升。

Parameters

X (数组形式, 形状 (n_samples, n_features)) – 训练向量,其中 n_samples 是样本数量,n_features 是特征数量。

Returns

提升

Return type

数组 (形状 (n_samples,))