当前位置: 首页 > article >正文

SingleTreePolicyInterpreter

https://github.com/py-why/EconML

用EconML进行决策

https://github.com/py-why/EconML

干预通常是有成本的:激励用户成为会员可能会有成本(例如提供折扣)。因此,我们目标是想知道哪些客户的的参与可以最大限度地提高利润。这是干预政策(treatment policy)。

EconML库包括策略可解释性工具,如SingleTreePolicyInterpreter,它考虑了干预成本和干预效果,以识别哪些客户可以带来盈利的简单规则。

intrp = SingleTreePolicyInterpreter(risk_level=0.05, max_depth=2, min_samples_leaf=10)
intrp.interpret(est_dw, test_customers, sample_treatment_costs=0.2)
plt.figure(figsize=(25, 5))
intrp.plot(feature_names=X_data.columns, fontsize=12)

 

SingleTreePolicyInterpreter例子

0.14.1
import econml
# 查看 econml 的版本
econml_version = econml.__version__
econml_version
from econml.dml import CausalForestDML
from econml.cate_interpreter import SingleTreePolicyInterpreter, SingleTreeCateInterpreter

#from econml.interpret import SingleTreePolicyInterpreter
from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import make_regression
%matplotlib inline
# 创建一个回归数据集
X, y = make_regression(n_samples=1000, n_features=10, n_informative=2, random_state=42)
# 假设其中一个特征对处理效应有影响
treatment_effect = X[:, 0] * 2
# 根据处理效应生成处理变量
treatment = (treatment_effect > 0).astype(int)

# 使用CausalForestDML模型
model = CausalForestDML(model_y=RandomForestRegressor(),
                        model_t=RandomForestRegressor(),
                        random_state=42)

# 拟合模型
model.fit(y, treatment, X=X)

# 创建解释器对象
intrp = SingleTreePolicyInterpreter(risk_level=0.05, max_depth=2, min_samples_leaf=1,min_impurity_decrease=.001)
intrp = SingleTreeCateInterpreter(include_model_uncertainty=True, max_depth=2, min_samples_leaf=10)

#interpreter = SingleTreePolicyInterpreter(max_depth=3, min_samples_leaf=10)
# 解释模型
#intrp.interpret(model, X, sample_treatment_costs=0.2)
intrp.interpret(model, X)
#interpreter.interpret(model, X, treatment, y)
# We interpret the CATE model's behavior based on the features used for heterogeneity

# Plot the tree
plt.figure(figsize=(25, 5))
intrp.plot(feature_names=['feature_0', 'feature_1', 'feature_2', 'feature_3', 'feature_4', 'feature_5', 'feature_6', 'feature_7', 'feature_8', 'feature_9'], fontsize=12)
plt.show()

参考

关于人工智能的因果推理领域有什么学习推荐? - 知乎

机器学习中有哪些涉及统计因果推断的算法? - 知乎

因果推断与反事实预测——利用DML进行价格弹性计算(二十四) - 知乎

【机器学习-因果推断】DoWhy+EconML 入门最佳案例:促销定价的因果效应 - 知乎

 


http://www.kler.cn/news/133876.html

相关文章:

  • k8s pod 处于Terminating的原因分析和解决处理——筑梦之路
  • 【Go入门】 Go的http包详解
  • QtC++与QUndoView详解
  • lv11 嵌入式开发 ARM指令集中(伪操作与混合编程) 7
  • P1304 哥德巴赫猜想
  • Fork/Join框架说明
  • OpenAI Assistants-API简明教程
  • 【人工智能Ⅰ】7-KNN 决策树
  • C复习-输入输出函数+流
  • MyBatis整合Spring Boot扫描Mapper相关配置
  • 在Ubuntu上用sane api实现通用扫描功能
  • Python OpenCV调整图像亮度对比度及RGB色彩
  • C++ ,VCPKG那些事
  • Linux终端与交互式Bash
  • 【数据分享】2023年我国省市县三级的独角兽企业数量(Excel/Shp格式)
  • 23111709[含文档+PPT+源码等]计算机毕业设计基于Spring Boot智能无人仓库管理-进销存储
  • 深度学习入门(第二天)——走进深度学习的世界 神经网络模型
  • 中级程序员——vue3+js+git面试题
  • 汽车虚拟仿真视频数据理解--CLIP模型原理
  • 【华为OD机试高分必刷题目】洗衣服(JavaPythonC++贪心算法实现)
  • 【数据结构(二)】单链表(3)
  • 三天吃透Redis面试八股文
  • ChatGPT之父被OpenAI解雇
  • 重生之我是一名程序员 35
  • map与set的封装
  • 【华为OD题库-027】代码编辑器-java
  • 设计模式-中介者模式-笔记
  • Perl的LWP::UserAgent库爬虫程序怎么写
  • 超大规模和隐私保护,融云如何助力 Web3 社交
  • C++ 20类型转换指南:使用场景与最佳实践