34
34
import math
35
35
import uuid
36
36
import numpy as np
37
+ import pandas as pd
37
38
from sklearn .base import BaseEstimator , ClassifierMixin , RegressorMixin
38
39
from sklearn .utils .validation import check_X_y , check_array , check_is_fitted
39
40
from sklearn .utils .multiclass import unique_labels
@@ -339,11 +340,7 @@ def plot(self):
339
340
check_is_fitted (self , 'is_fitted_' )
340
341
I = self .I_
341
342
F = self ._get_signed_F ()
342
- axis_labels = (
343
- [ am ._score_func .__name__ for am in self .accuracy_metrics_ ]
344
- + [ fn .__name__ for fn in self .fairness_metrics_ ]
345
- )
346
- axis_labels = [al .replace ('_' ,' ' ) for al in axis_labels ]
343
+ axis_labels = self ._get_objective_names ()
347
344
plot = (
348
345
Scatter ()
349
346
.add (F , alpha = 0.2 , label = 'Candidate models' )
@@ -367,12 +364,21 @@ def _get_signed_F(self, F=None):
367
364
F [:,i ] = F [:,i ]* m ._sign
368
365
return F
369
366
367
+ def _get_objective_names (self ):
368
+ """Returns names of functions defining the objectives"""
369
+ labels = (
370
+ [ m ._score_func .__name__ for m in self .accuracy_metrics_ ]
371
+ + [ fn .__name__ for fn in self .fairness_metrics_ ]
372
+ )
373
+ labels = [l .replace ('_' ,' ' ) for l in labels ]
374
+ return labels
375
+
370
376
def get_pareto_points (self ):
371
377
"""Return a Pandas dataframe of the Pareto archive points"""
372
- archive = pd . DataFrame (
373
- self ._get_signed_F (),
374
- columns = self .accuracy_metrics_ + self . fairness_metrics_
375
- )
378
+ F = self . _get_signed_F ()
379
+ I = self .I_
380
+ archive = pd . DataFrame ( F , columns = self ._get_objective_names ())
381
+ archive [ 'chosen' ] = [ all ( f == F [ I ]) for f in F ]
376
382
return archive
377
383
378
384
class FomoClassifier (FomoEstimator , ClassifierMixin , BaseEstimator ):
0 commit comments