Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Implements metrics.
4"""
5import sklearn.metrics as skmetrics
6from .classification import roc_auc_score_micro, roc_auc_score_macro, reshape, multi_label_jaccard
7from .regression import mse
8from .regression_custom import l1_reg_max
11def sklearn_metric(met, exp, val):
12 """
13 Looks into metrics available in
14 :epkg:`scikit-learn:metrics`.
16 @param met function name
17 @param exp expected values
18 @param val values
19 @return number
20 """
21 if isinstance(val, str):
22 raise TypeError("val must be a container of floats")
23 if isinstance(exp, str):
24 raise TypeError("exp must be a container of floats")
25 if hasattr(skmetrics, met):
26 f = getattr(skmetrics, met)
27 exp, val = reshape(exp, val)
28 return f(exp, val)
29 else:
30 raise AttributeError("Unable to find metric '{0}'.".format(met))