Exemple #1
0
def f_clf1(hps):
    # Assembing pipeline
    #weights = [hps['acc_w'], hps['fair_w'], hps['rob_w']]
    #weights = [0.0, 1.0, 0.0]
    #rankings = [accuracy_ranking, fairness_ranking, robustness_ranking]

    #weights = [hps['var_w']]
    #rankings = [variance_ranking]
    #weights = [hps['acc_w']]
    #rankings = [accuracy_ranking]
    #weights = [hps['fair_w']]
    #rankings = [fairness_ranking]

    weights = [hps['acc_w'], hps['fair_w'], hps['var_w']]
    rankings = [accuracy_ranking, fairness_ranking, variance_ranking]

    mask = np.zeros(len(hps) - 5, dtype=bool)
    for k, v in hps.items():
        if k.startswith('f_'):
            mask[int(k.split('_')[1])] = v

    clf = LogisticRegression()
    if type(privacy_epsilon) != type(None):
        clf = models.LogisticRegression(epsilon=privacy_epsilon)

    model = Pipeline([('selection',
                       WeightedRankingSelection(scores=rankings,
                                                weights=weights,
                                                k=hps['k'] + 1,
                                                names=np.array(names),
                                                hyperparameter_mask=mask)),
                      ('clf', clf)])

    return model
Exemple #2
0
def f_clf1(hps):
    # Assembing pipeline
    #weights = [hps['acc_w'], hps['fair_w'], hps['rob_w']]
    #weights = [0.0, 1.0, 0.0]
    #rankings = [accuracy_ranking, fairness_ranking, robustness_ranking]

    #weights = [hps['var_w']]
    #rankings = [variance_ranking]
    #weights = [hps['acc_w']]
    #rankings = [accuracy_ranking]
    #weights = [hps['fair_w']]
    #rankings = [fairness_ranking]

    weights = [hps['acc_w'], hps['fair_w'], hps['var_w']]
    rankings = [accuracy_ranking, fairness_ranking, variance_ranking]
    #weights = [hps['acc_w'], hps['fair_w'], hps['var_w'], hps['rob_w']]
    #rankings = [accuracy_ranking, fairness_ranking, variance_ranking, robustness_ranking]

    clf = LogisticRegression()
    if type(privacy_epsilon) != type(None):
        clf = models.LogisticRegression(epsilon=privacy_epsilon)

    model = Pipeline([('selection',
                       WeightedRankingSelection(scores=rankings,
                                                weights=weights,
                                                k=hps['k'] + 1,
                                                names=np.array(names))),
                      ('clf', clf)])

    return model
Exemple #3
0
	def f_clf1(hps):
		weights = []
		for i in range(len(rankings)):
			weights.append(hps['weight' + str(i)])

		pipeline = Pipeline([
			('selection', WeightedRankingSelection(scores=rankings, weights=weights, k=hps['k'], names=np.array(names))),
			('clf', clf)
		])

		return pipeline
Exemple #4
0
def get_knn(hps):
    # Assembing pipeline
    weights = [hps['acc_w'], hps['fair_w'], hps['rob_w']]
    #weights = [0.0, 1.0, 0.0]
    rankings = [accuracy_ranking, fairness_ranking, robustness_ranking]

    clf = KNeighborsClassifier(n_neighbors=3)
    #if type(privacy_epsilon) != type(None):
    #	clf = models.LogisticRegression(epsilon=privacy_epsilon)

    model = Pipeline([('selection',
                       WeightedRankingSelection(scores=rankings,
                                                weights=weights,
                                                k=hps['k'] + 1,
                                                names=np.array(names))),
                      ('clf', clf)])

    return model
Exemple #5
0
def f_clf1(hps):
    # Assembing pipeline
    weights = [hps['acc_w'], hps['fair_w'], hps['rob_w']]
    #weights = [0.0, 1.0, 0.0]
    rankings = [accuracy_ranking, fairness_ranking, robustness_ranking]

    clf = LogisticRegression()
    if type(privacy_epsilon) != type(None):
        clf = models.LogisticRegression(
            epsilon=privacy_epsilon
        )  #The smaller the value is, the better privacy protection

    model = Pipeline([('selection',
                       WeightedRankingSelection(scores=rankings,
                                                weights=weights,
                                                k=hps['k'] + 1,
                                                names=np.array(names))),
                      ('clf', clf)])

    return model