-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add compas examples - model and reality examples
- Loading branch information
1 parent
79091e8
commit d15981d
Showing
10 changed files
with
283 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[report] | ||
omit = | ||
setup.py | ||
*test* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
u""" | ||
© 2023 Telefónica Digital España S.L. | ||
This file is part of XAIoGraphs. | ||
XAIoGraphs is free software: you can redistribute it and/or modify it under the terms of the Affero GNU General Public | ||
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any | ||
later version. | ||
XAIoGraphs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Affero GNU General Public License | ||
for more details. | ||
You should have received a copy of the Affero GNU General Public License along with XAIoGraphs. If not, | ||
see https://www.gnu.org/licenses/.""" | ||
|
||
from xaiographs import Explainer | ||
from xaiographs import Why | ||
from xaiographs.datasets import load_compas_reality_discretized, load_compas_reality_why | ||
|
||
LANG = 'en' | ||
|
||
# LOAD DATASETS & SEMANTICS | ||
df_compas, feature_cols, target_cols = load_compas_reality_discretized() | ||
df_values_semantics, df_target_values_semantics = load_compas_reality_why(language=LANG) | ||
|
||
# EXPLAINER | ||
explainer = Explainer(importance_engine='LIDE', verbose=1) | ||
explainer.fit(df=df_compas, feature_cols=feature_cols, target_cols=target_cols) | ||
|
||
# WHY | ||
why = Why(language=LANG, | ||
explainer=explainer, | ||
why_values_semantics=df_values_semantics, | ||
why_target_values_semantics=df_target_values_semantics, | ||
verbose=1) | ||
why.fit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
xaiographs/datasets/data/compas_reality/target_values_semantics_en.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
target,feature_value,reason | ||
Recid,Age_range_25 - 45,some in the age range between 25 and 45 years were repeat offenders | ||
Recid,Age_range_Greater than 45,few of those over 45 were repeat offenders | ||
Recid,Age_range_Less than 25,many of those under 25 years of age were repeat offenders | ||
Recid,is_recid_NO,few were Non-recidivists | ||
Recid,is_recid_YES,many were repeat offenders | ||
Recid,is_violent_recid_NO,few were No Violent Repeat Offenders | ||
Recid,is_violent_recid_YES,many were Violent Repeat Offenders | ||
No_Recid,Age_range_25 - 45,some in the age range between 25 and 45 years were repeat offenders | ||
No_Recid,Age_range_Greater than 45,many of those over 45 years of age were repeat offenders | ||
No_Recid,Age_range_Less than 25,few people under 25 years of age were repeat offenders | ||
No_Recid,is_recid_NO,many were Non-recidivists | ||
No_Recid,is_recid_YES,few were repeat offenders | ||
No_Recid,is_violent_recid_NO,many were Non-Violent Repeat Offenders | ||
No_Recid,is_violent_recid_YES,few were Violent Repeat Offenders |
15 changes: 15 additions & 0 deletions
15
xaiographs/datasets/data/compas_reality/target_values_semantics_es.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
target,feature_value,reason | ||
Recid,Age_range_25 - 45,algunos del rango de edad entre 25 y 45 años fueron reincidentes | ||
Recid,Age_range_Greater than 45,pocos de los mayores de 45 años fueron reincidentes | ||
Recid,Age_range_Less than 25,muchos de los menores de 25 años fueron reincidentes | ||
Recid,is_recid_NO,pocos eran No Reincidentes | ||
Recid,is_recid_YES,muchos eran Reincidentes | ||
Recid,is_violent_recid_NO,pocos eran No Reincidentes Violentos | ||
Recid,is_violent_recid_YES,muchos eran Reincidentes Violentos | ||
No_Recid,Age_range_25 - 45,algunos del rango de edad entre 25 y 45 años fueron reincidentes | ||
No_Recid,Age_range_Greater than 45,muchos de los mayores de 45 años fueron reincidentes | ||
No_Recid,Age_range_Less than 25,pocos menores de 25 años fueron reincidentes | ||
No_Recid,is_recid_NO,muchos eran No Reincidentes | ||
No_Recid,is_recid_YES,pocos eran Reincidentes | ||
No_Recid,is_violent_recid_NO,muchos eran No Reincidentes Violentos | ||
No_Recid,is_violent_recid_YES,pocos eran Reincidentes Violentos |
8 changes: 8 additions & 0 deletions
8
xaiographs/datasets/data/compas_reality/values_semantics_en.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
feature_value,reason | ||
Age_range_25 - 45,middle-aged | ||
Age_range_Greater than 45,be older than 45 years | ||
Age_range_Less than 25,be young | ||
is_recid_NO,not being a repeat offender | ||
is_recid_YES,be a repeat offender | ||
is_violent_recid_NO,not being a repeat offender | ||
is_violent_recid_YES,be a violent repeat offender |
8 changes: 8 additions & 0 deletions
8
xaiographs/datasets/data/compas_reality/values_semantics_es.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
feature_value,reason | ||
Age_range_25 - 45,ser de mediana edad | ||
Age_range_Greater than 45,ser mayor de 45 años | ||
Age_range_Less than 25,ser joven | ||
is_recid_NO,no ser reincidente | ||
is_recid_YES,ser reincidente | ||
is_violent_recid_NO,no ser reincidente | ||
is_violent_recid_YES,ser reincidente violento |
Oops, something went wrong.