机器学习可解释性工具箱XAI

http://blog.itpub.net/29829936/viewspace-2600454/

 

XAI是Github上的一个机器学习可解释性工具箱。XAI包含多种分析和评价数据和模型的工具。XAI在开发时遵循负责的机器学习的8个原则。

XAI是Github上的一个机器学习可解释性工具箱,地址为:

https://github.com/EthicalML/xai

安装及一些简单的用例如下:

安装

pip install xai

简单用例

XAI可以识别数据不平衡。我们先载入census数据集:

import xai.data
df = xai.data.load_census()
df.head()

 

查看多列类别不平衡:

protected_cols = ["gender", "ethnicity", "age"]
ims = xai.show_imbalances(df, protected_cols)

 

查看一列类别不平衡:

im = xai.show_imbalance(df, "gender")

 

查看一列与另一列相交的不平衡:

im = xai.show_imbalance(df, "gender", cross=["loan"])

 

利用上采样或下采样进行平衡:

bal_df = xai.balance(df, "gender", cross=["loan"], upsample=1.0)

 

创建一个平衡的测试-训练划分:

# Balanced train-test split with minimum 300 examples of 
# the cross of the target y and the column gender
x_train, y_train, x_test, y_test = xai.balanced_train_test_split(
 x, y, cross=["gender"], 
 categorical_cols=categorical_cols, min_per_class=300)
# Visualise the imbalances of gender and the target 
df_test = x_test.copy()
df_test["loan"] = y_test
_= xai.show_imbalance(df_test, "gender", cross=["loan"], categorical_cols=categorical_cols)

 

更多用例可以参考Github项目链接:

https://github.com/EthicalML/xai

你可能感兴趣的:(人工智能,机器学习,可解释工具箱,XAI)