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
import sys; sys.path.extend(['..'])
import numpy as np
import pandas as pd
from nltk.corpus import stopwords
......@@ -6,12 +8,8 @@ from nltk import pos_tag
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
from time import time
from core_text import FixOutText
# Import data
df = pd.read_csv("datasets/english_variant.csv")
......
import datetime
import sys; sys.path.extend(['..'])
from core import FixOut, evaluation, Model, fairness_metrics_eval, \
evaluation_fixed_threshold
from datasets_param import *
import datetime
from fixout.core import FixOut, evaluation, Model, evaluation_fixed_threshold
from examples.datasets_param import *
from fairmodels import ModelProb, FairnessObject
import numpy as np
import pandas as pd
......@@ -63,8 +63,8 @@ def one_experiment(source_name, sep, train_size, to_drop, all_categorical_featur
test_input = pd.DataFrame(fixout.test.astype(np.uint8), columns=fixout.feature_names)
original_predictions = ModelProb(fixout.original_model.prob(fixout.test)[:,1], threshold=0.5, name="Original")
fixout_predictions = ModelProb(fixout.ensemble.prob(fixout.test)[:,1], threshold=0.5, name="Ensemble")
original_predictions = ModelProb(fixout.original_model.predict_proba(fixout.test)[:, 1], threshold=0.5, name="Original")
fixout_predictions = ModelProb(fixout.ensemble.predict_proba(fixout.test)[:, 1], threshold=0.5, name="Ensemble")
fobject = FairnessObject(
model_probs=[original_predictions, fixout_predictions],
......@@ -147,4 +147,3 @@ if __name__ == "__main__":
print("Data Parameters:",dataset_param)
print("General Parameters:",general_parameters)
main(general_parameters, dataset_param)
\ No newline at end of file
import sys
import sys; sys.path.extend(['..'])
import warnings
import datetime
from core import FixOut
from fixout.core import FixOut
from runner import algo_parser, exp_parser
from datasets_param import *
from examples.datasets_param import *
def one_experiment(source_name, sep, train_size, to_drop, all_categorical_features, max_features, algo, exp, sampling_size, threshold_exp):
......
import sys; sys.path.extend(['..'])
import numpy as np
import pandas as pd
from nltk.corpus import stopwords
......@@ -6,13 +8,11 @@ from nltk import pos_tag
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
from time import time
from core_text import FixOutText
from fixout.core_text import FixOutText
hsdata = pd.read_csv("datasets/hate_speech.csv")
class_names = np.array(["ok", "hate speech"])
......
import sys; sys.path.extend(['..'])
import numpy as np
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.ensemble import RandomForestClassifier
from sklearn.pipeline import make_pipeline
from sklearn.metrics import accuracy_score
from core_text import FixOutText
from fixout.core_text import FixOutText
from time import time
......
# from .core import FixOut
from .core_text import FixOutText
\ No newline at end of file
from collections import Counter
from anchor import anchor_tabular
import lime_global
from fixout.anchor import anchor_tabular
from fixout import lime_global
import pandas as pd
import numpy as np
def fairness_eval(model, train, max_features, sensitive_features, feature_names, class_names, categorical_features, categorical_names):
_, sp_obj = lime_global.features_contributions(model.prob, train, feature_names, max_features, class_names, categorical_features, categorical_names)
_, sp_obj = lime_global.features_contributions(model.predict_proba, train, feature_names, max_features, class_names, categorical_features, categorical_names)
a = Counter()
for i in sp_obj.V:
......@@ -27,7 +27,7 @@ def fairness_eval(model, train, max_features, sensitive_features, feature_names,
indices = sp_obj.indices
a_explainer = anchor_tabular.AnchorTabularExplainer(class_names,feature_names,train,categorical_names=categorical_names)
a_explainer = anchor_tabular.AnchorTabularExplainer(class_names, feature_names, train, categorical_names=categorical_names)
non_empty_anchors = 0
counter = Counter()
......
from . import anchor_base
from . import anchor_explanation
from . import utils
import lime
import lime.lime_tabular
import fixout.lime.lime_tabular
import collections
import sklearn
import numpy as np
import os
import copy
......@@ -46,13 +43,13 @@ class AnchorTabularExplainer(object):
self.categorical_features = sorted(categorical_names.keys())
if discretizer == 'quartile':
self.disc = lime.lime_tabular.QuartileDiscretizer(train_data,
self.categorical_features,
self.feature_names)
self.disc = fixout.lime.lime_tabular.QuartileDiscretizer(train_data,
self.categorical_features,
self.feature_names)
elif discretizer == 'decile':
self.disc = lime.lime_tabular.DecileDiscretizer(train_data,
self.categorical_features,
self.feature_names)
self.disc = fixout.lime.lime_tabular.DecileDiscretizer(train_data,
self.categorical_features,
self.feature_names)
else:
raise ValueError('Discretizer must be quartile or decile')
......
from . import utils
from . import anchor_base
from . import anchor_explanation
import numpy as np
import json
import os
import string
import sys
from io import open
import numpy as np
......
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