Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 0f79e17c authored by BERNIER Fabien's avatar BERNIER Fabien
Browse files

[~] reorganization of the project structure

parent 9e960077
......@@ -13,11 +13,11 @@ import sklearn
import sklearn.preprocessing
from sklearn.utils import check_random_state
from lime.discretize import QuartileDiscretizer
from lime.discretize import DecileDiscretizer
from lime.discretize import EntropyDiscretizer
from lime.discretize import BaseDiscretizer
from lime.discretize import StatsDiscretizer
from fixout.lime.discretize import QuartileDiscretizer
from fixout.lime.discretize import DecileDiscretizer
from fixout.lime.discretize import EntropyDiscretizer
from fixout.lime.discretize import BaseDiscretizer
from fixout.lime.discretize import StatsDiscretizer
from . import explanation
from . import lime_base
......
......@@ -418,8 +418,8 @@ class LimeTextExplainer(object):
distance_metric=distance_metric)
except:
ret_exp = explanation.Explanation(domain_mapper=domain_mapper,
class_names=self.class_names,
random_state=self.random_state)
class_names=self.class_names,
random_state=self.random_state)
ret_exp.predict_proba = classifier_fn([text_instance])[0]
ret_exp.local_pred = [ret_exp.predict_proba[1]]
ret_exp.intercept[1] = ret_exp.predict_proba[1]
......
......@@ -5,7 +5,7 @@ import numpy as np
from sklearn.datasets import load_iris
from lime.discretize import QuartileDiscretizer, DecileDiscretizer, EntropyDiscretizer
from fixout.lime.discretize import QuartileDiscretizer, DecileDiscretizer, EntropyDiscretizer
class TestDiscretize(TestCase):
......
......@@ -3,15 +3,13 @@ import unittest
import numpy as np
import collections
import sklearn # noqa
import sklearn.datasets
import sklearn.ensemble
import sklearn.linear_model # noqa
from numpy.testing import assert_array_equal
from sklearn.datasets import load_iris, make_classification, make_multilabel_classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import Lasso
from sklearn.linear_model import LinearRegression
from lime.discretize import QuartileDiscretizer, DecileDiscretizer, EntropyDiscretizer
from fixout.lime.discretize import QuartileDiscretizer, DecileDiscretizer, EntropyDiscretizer
try:
......@@ -20,7 +18,7 @@ except ImportError:
# Deprecated in scikit-learn version 0.18, removed in 0.20
from sklearn.cross_validation import train_test_split
from lime.lime_tabular import LimeTabularExplainer
from fixout.lime.lime_tabular import LimeTabularExplainer
class TestLimeTabular(unittest.TestCase):
......
......@@ -11,8 +11,8 @@ from sklearn.pipeline import make_pipeline
import numpy as np
from lime.lime_text import LimeTextExplainer
from lime.lime_text import IndexedCharacters, IndexedString
from fixout.lime.lime_text import LimeTextExplainer
from fixout.lime.lime_text import IndexedCharacters, IndexedString
class TestLimeText(unittest.TestCase):
......
......@@ -3,19 +3,16 @@ Implements LIME_Global. Verifies if sensitives features have high contributions.
"""
from collections import Counter
import pandas as pd
import numpy as np
import sys
import numpy as np
from lime import lime_tabular, submodular_pick
from scipy import stats
from fixout.lime import submodular_pick, lime_tabular
clusters=50
def features_contributions(predict_fn, train, feature_names, max_features, class_names, categorical_features, categorical_names, sample_size, kernel_width=3):
# sys.stdout = None
explainer = lime_tabular.LimeTabularExplainer(train,feature_names=feature_names,class_names=class_names,categorical_features=categorical_features,categorical_names=categorical_names,kernel_width=kernel_width)
explainer = lime_tabular.LimeTabularExplainer(train, feature_names=feature_names, class_names=class_names, categorical_features=categorical_features, categorical_names=categorical_names, kernel_width=kernel_width)
num_features = len(feature_names) if max_features <= 0 else max_features
......@@ -25,7 +22,7 @@ def features_contributions(predict_fn, train, feature_names, max_features, class
def fairness_eval(model, train, max_features, sensitive_features, feature_names, class_names, categorical_features, categorical_names, sample_size, threshold=None):
explainer, sp_obj = features_contributions(model.prob, train, feature_names, max_features, class_names, categorical_features, categorical_names, sample_size)
explainer, sp_obj = features_contributions(model.predict_proba, train, feature_names, max_features, class_names, categorical_features, categorical_names, sample_size)
contributions = Counter()
for i in sp_obj.V:
......
......@@ -5,8 +5,7 @@ from collections import Counter
import pandas as pd
import numpy as np
from lime import submodular_pick
from lime.lime_text import LimeTextExplainer
from fixout.lime.lime_text import LimeTextExplainer
clusters = 50
......@@ -27,7 +26,7 @@ def features_contributions(predict_fn, train, class_names, sample_size, kernel_w
def fairness_eval(model, train, max_features, sensitive_features, feature_names, class_names, sample_size, threshold=None):
explainer, explanations = features_contributions(model.prob, train, class_names, sample_size)
explainer, explanations = features_contributions(model.predict_proba, train, class_names, sample_size)
contributions = Counter()
for exp in explanations:
......
......@@ -20,7 +20,7 @@ def features_contributions(predict_fn, train, feature_names, max_features, class
def fairness_eval(model, train, max_features, sensitive_features, feature_names, class_names, categorical_features, categorical_names, sample_size, threshold=None):
explainer, shap_values = features_contributions(model.prob, train, feature_names, max_features, class_names, categorical_features, categorical_names, sample_size)
explainer, shap_values = features_contributions(model.predict_proba, train, feature_names, max_features, class_names, categorical_features, categorical_names, sample_size)
n_features = len(feature_names)
......
......@@ -10,11 +10,8 @@ from sklearn.mixture._gaussian_mixture import GaussianMixture
from sklearn.neural_network._multilayer_perceptron import MLPClassifier
from sklearn.svm._classes import SVC
import anchor_global
import lime_text_global
from core import FixOut
import lime_global
import shap_global
from fixout import anchor_global, shap_global, lime_text_global, lime_global
from fixout import FixOut
from sklearn.tree import DecisionTreeClassifier
......@@ -74,7 +71,7 @@ def exp_parser(algo_str):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='ExpOut: process fairness for classification')
parser = argparse.ArgumentParser(description='FixOut: process fairness for classification')
parser.add_argument('--data')
parser.add_argument('--trainsize', type=float)
parser.add_argument('--algo')
......@@ -91,4 +88,4 @@ if __name__ == "__main__":
now = datetime.datetime.now()
print(now.year,'-', now.month,'-', now.day,',', now.hour,':', now.minute,':', now.second,sep='')
main(args.data, args.sep, args.trainsize, args.drop_list, args.cat_features_list, args.max_features, algo_parser(args.algo), exp_parser(args.exp), args.samplesize)#, args.fairecriteria)
\ No newline at end of file
main(args.data, args.sep, args.trainsize, args.drop_list, args.cat_features_list, args.max_features, algo_parser(args.algo), exp_parser(args.exp), args.samplesize)#, args.fairecriteria)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment