def __init__(self, data): # User defined arguments fixed_random_seed = 0xbeef train_data_sampler = CompleteData() missing_value_handler = CompleteCaseAnalysis() numeric_attribute_scaler = NoScaler() learners = [ NonTunedLogisticRegression(), NonTunedDecisionTree() ] pre_processors = [NoPreProcessing()] post_processors = [NoPostProcessing()] # Fixed arguments for dataset test_set_ratio = 0.2 validation_set_ratio = 0.1 label_name = 'credit' positive_label = 1 numeric_attribute_names = [ 'month', 'credit_amount', 'residence_since', 'age', 'number_of_credits', 'people_liable_for' ] categorical_attribute_names = [ 'credit_history', 'savings', 'employment' ] attributes_to_drop_names = [ 'personal_status', 'status', 'purpose', 'investment_as_income_percentage', 'other_debtors', 'property', 'installment_plans', 'housing', 'skill_level', 'telephone', 'foreign_worker' ] protected_attribute_names = ['sex'] privileged_classes = [[1.0]] privileged_groups = [{'sex': 1.0}] unprivileged_groups = [{'sex': 0.0}] dataset_metadata = { 'label_maps': [{ 1.0: 1, 0.0: 0 }], 'protected_attribute_maps': [{ 1.0: 'male', 0.0: 'female' }] } dataset_name = 'test_dataset' # Constructor call super().__init__( fixed_random_seed, test_set_ratio, validation_set_ratio, label_name, positive_label, numeric_attribute_names, categorical_attribute_names, attributes_to_drop_names, train_data_sampler, missing_value_handler, numeric_attribute_scaler, learners, pre_processors, post_processors, protected_attribute_names, privileged_classes, privileged_groups, unprivileged_groups, dataset_metadata, dataset_name)
def test_GiveMeSomeCreditExperiment(self): self.experiment = GiveMeSomeCreditExperiment( fixed_random_seed=0xabcd, train_data_sampler=CompleteData(), missing_value_handler=CompleteCaseAnalysis(), numeric_attribute_scaler=NamedStandardScaler(), learners=[NonTunedLogisticRegression(), NonTunedDecisionTree()], pre_processors=[NoPreProcessing()], post_processors=[NoPostProcessing()]) self.experiment.run()
from fp.dataset_experiments import GermanCreditDatasetSexExperiment from fp.scalers import NamedStandardScaler, NamedMinMaxScaler from fp.learners import NonTunedLogisticRegression, LogisticRegression, DecisionTree, NonTunedLogisticRegression, NonTunedDecisionTree from fp.post_processors import NoPostProcessing, RejectOptionPostProcessing, EqualOddsPostProcessing, CalibratedEqualOddsPostProcessing from fp.pre_processors import NoPreProcessing, DIRemover, Reweighing import numpy as np import matplotlib.pyplot as plt #creating list of parameters that we will alter to observe variations seeds = [ 0xbeef, 0xcafe, 0xdead, 0xdeadcafe, 0xdeadbeef, 0xbeefcafe, 0xcafebeef, 50, 583, 5278, 100000, 0xefac, 0xfeeb, 0xdaed, 0xefacdaed, 0xfeebdead ] learners = [ NonTunedLogisticRegression(), LogisticRegression(), NonTunedDecisionTree(), DecisionTree() ] processors = [(NoPreProcessing(), NoPostProcessing()), (DIRemover(1.0), NoPostProcessing()), (DIRemover(0.5), NoPostProcessing()), (Reweighing(), NoPostProcessing()), (NoPreProcessing(), RejectOptionPostProcessing()), (NoPreProcessing(), CalibratedEqualOddsPostProcessing())] def calculate_metrics(seed, learner, pre_processor, post_processor): ''' Experiment function to run the experiments
def test_NonTunedLogisticRegression(self): self.learner = NonTunedLogisticRegression() result = self.learner.fit_model(self.annotated_data, self.seed) self.assertEqual(self.learner.name(), 'LogisticRegression-notuning') self.assertEqual(type(result), type(SGDClassifier()))