機器學習可解釋性工具箱XAI

dicksonjyl560101發表於2019-02-08

https://www.toutiao.com/a6655533972774191619/


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()
機器學習可解釋性工具箱XAI

檢視多列類別不平衡:

protected_cols = ["gender", "ethnicity", "age"]
ims = xai.show_imbalances(df, protected_cols)
機器學習可解釋性工具箱XAI

檢視一列類別不平衡:

im = xai.show_imbalance(df, "gender")
機器學習可解釋性工具箱XAI

檢視一列與另一列相交的不平衡:

im = xai.show_imbalance(df, "gender", cross=["loan"])
機器學習可解釋性工具箱XAI

利用上取樣或下采樣進行平衡:

bal_df = xai.balance(df, "gender", cross=["loan"], upsample=1.0)
機器學習可解釋性工具箱XAI

建立一個平衡的測試-訓練劃分:

# 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)
機器學習可解釋性工具箱XAI

更多用例可以參考Github專案連結:

https://github.com/EthicalML/xai


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29829936/viewspace-2600454/,如需轉載,請註明出處,否則將追究法律責任。

相關文章