解释机器学习模型的反事实——python工具箱

ceml的Python项目详细描述


ceml是一个用于计算反事实的python工具箱。反事实可以用来解释机器学习模型的预测。

它支持许多常见的机器学习框架:

  • scikit-learn
  • PyTorch
  • Keras
  • Tensorflow

此外,ceml易于使用,并且可以很容易地扩展。有关如何使用和扩展CEML的详细信息,请参阅以下用户指南。

安装

注意:需要python 3.6或更高版本!

Pypi

pip install ceml

注意:托管在pypi上的包仅使用cpu。如果要使用GPU,必须手动安装CEML—请参阅下一节。

吉特

下载或克隆存储库:

git clone https://github.com/andreArtelt/ceml.git
cd ceml

安装所有要求(在requirements.txt中列出):

pip install -r requirements.txt

注意:如果要使用gpu/tpu,必须手动安装jax、tensorflow和pytorch的gpu版本。不要使用pip install -r requirements.txt

安装工具箱本身:

pip install

快速示例

#!/usr/bin/env python3# -*- coding: utf-8 -*-fromsklearn.datasetsimportload_irisfromsklearn.model_selectionimporttrain_test_splitfromsklearn.metricsimportaccuracy_scorefromsklearn.treeimportDecisionTreeClassifierfromceml.sklearnimportgenerate_counterfactualif__name__=="__main__":# Load dataX,y=load_iris(True)X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.33,random_state=4242)# Whitelist of features - list of features we can change/use when computing a counterfactualfeatures_whitelist=None# We can use all features# Create and fit modelmodel=DecisionTreeClassifier(max_depth=3)model.fit(X_train,y_train)# Select data point for explaining its predictionx=X_test[1,:]print("Prediction on x: {0}".format(model.predict([x])))# Compute counterfactualprint("\nCompute counterfactual ....")print(generate_counterfactual(model,x,y_target=0,features_whitelist=features_whitelist))

文档

文档可在readthedocs上获得:https://ceml.readthedocs.io/en/latest/

许可证

麻省理工学院许可证-请参见LICENSE.md

如何引用?

You can cite ceml by using the following BibTeX entry:

@misc{ceml,
        author = {André Artelt},
        title = {CEML: Counterfactuals for Explaining Machine Learning models - A Python toolbox},
        year = {2019},
        publisher = {GitHub},
        journal = {GitHub repository},
        howpublished = {\url{https://www.github.com/andreArtelt/ceml}}
    }

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在reducer中迭代自定义可写组件时出现java问题   属性文件中属性的java命名约定   任务链关闭的java Executor服务   java从Eclipse中的字段生成多个构造函数   java通过继承读取Json   java在不知道密钥的情况下解析json   java camel cxf如何在电子邮件中发送soap请求响应   java程序似乎跳过了if语句的一部分,在移回正确位置之前先移到else语句   测试简单的Java加密/解密inputFileName不存在   java从Jenkins REST API获取所有作业的所有构建的构建细节   java基本包装器和静态“类型”类对象   在WebSphere8.5上部署java代码   java对象相等(对象引用“=”)   java MongoDB整型字段到枚举的转换   每次我重新导入gradle时,IntelliJ都会不断重置Java设置   类型使用键或索引从Java中的数据类型检索值   在Java的列表接口中需要listIterator()和iterator()是什么?