Skip to content
Snippets Groups Projects
Commit d33b9961 authored by Baptiste Bauvin's avatar Baptiste Bauvin
Browse files

WE work

parent 268c0165
Branches
Tags
No related merge requests found
Showing
with 20 additions and 22 deletions
......@@ -11,7 +11,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
"""Arguments:
y_true: real labels
y_pred predicted labels
......
......@@ -11,7 +11,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......@@ -27,7 +27,7 @@ def score(y_true, y_pred, **kwargs):
try:
average = kwargs["3"]
except:
if set(y_true) != {0,1} or (set(y_pred) != {0,1} and set(y_pred) != {0} and set(y_pred) != {1}):
if multiclass:
average = "micro"
else:
average = "binary"
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......@@ -26,7 +26,7 @@ def score(y_true, y_pred, **kwargs):
try:
average = kwargs["4"]
except:
if set(y_true) != {0,1} or (set(y_pred) != {0,1} and set(y_pred) != {0} and set(y_pred) != {1}):
if multiclass:
average = "micro"
else:
average = "binary"
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
classes = kwargs["0"]
except:
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
score = metric(y_true, y_pred)
return score
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......@@ -22,7 +22,7 @@ def score(y_true, y_pred, **kwargs):
try:
average = kwargs["3"]
except:
if set(y_true) != {0,1} or (set(y_pred) != {0,1} and set(y_pred) != {0} and set(y_pred) != {1}):
if multiclass:
average = "micro"
else:
average = "binary"
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......@@ -22,7 +22,7 @@ def score(y_true, y_pred, **kwargs):
try:
average = kwargs["3"]
except:
if set(y_true) != {0,1} or (set(y_pred) != {0,1} and set(y_pred) != {0} and set(y_pred) != {1}):
if multiclass:
average = "micro"
else:
average = "binary"
......
......@@ -7,7 +7,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......@@ -15,11 +15,11 @@ def score(y_true, y_pred, **kwargs):
try:
average = kwargs["1"]
except:
if set(y_true) != {0,1} or (set(y_pred) != {0,1} and set(y_pred) != {0} and set(y_pred) != {1}):
if multiclass:
average = "micro"
else:
average = None
if set(y_true) != {0,1} or (set(y_pred) != {0,1} and set(y_pred) != {0} and set(y_pred) != {1}):
if multiclass:
mlb = MultiLabelBinarizer()
y_true = mlb.fit_transform([(label) for label in y_true])
y_pred = mlb.fit_transform([(label) for label in y_pred])
......
......@@ -6,7 +6,7 @@ __author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
def score(y_true, y_pred, **kwargs):
def score(y_true, y_pred, multiclass=False, **kwargs):
try:
sample_weight = kwargs["0"]
except:
......
......@@ -218,9 +218,10 @@ def genMetricsScoresMulticlass(results, trueLabels, metrics, argumentsDictionari
for classifierName, resultDictionary in iterResults.items():
if not "metricsScores" in resultDictionary:
results[iterIndex][classifierName]["metricsScores"]={}
trainScore = metricModule.score(trueLabels[trainIndices],resultDictionary["labels"][trainIndices])
trainScore = metricModule.score(trueLabels[trainIndices],resultDictionary["labels"][trainIndices], multiclass=True)
testScore = metricModule.score(trueLabels[multiclassTestIndices],
resultDictionary["labels"][multiclassTestIndices])
resultDictionary["labels"][multiclassTestIndices],
multiclass=True)
results[iterIndex][classifierName]["metricsScores"][metric[0]] = [trainScore, testScore]
......@@ -720,8 +721,6 @@ def resultAnalysis(benchmark, results, name, times, metrics, directory, minSize=
logging.debug("Done:\t Score graph generation for " + metric[0])
def analyzeLabels(labelsArrays, realLabels, results, directory, minSize = 10):
"""Used to generate a graph showing errors on each example depending on classifier"""
logging.debug("Start:\t Label analysis figure generation")
......@@ -807,7 +806,6 @@ def analyzeIterLabels(labelsAnalysisList, directory, classifiersNames, minSize=1
logging.debug("Done:\t Global error by example figure generation")
def genFig(iterResults, metric, nbResults, names, nbMono, minSize=10):
"""Used to generate the bar graph representing the mean scores of each classifiers if multiple iteration
with different random states"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment