Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (18 sloc) 789 Bytes
"""Explained Variance. Fraction of variance that is explained by the model."""
import typing
import numpy as np
from h2oaicore.metrics import CustomScorer
import sklearn
class MyExplainedVarianceScorer(CustomScorer):
_description = "My Explained Variance Scorer for Regression."
_regression = True
_maximize = True
_perfect_score = 1
_display_name = "ExpVar"
def score(self,
actual: np.array,
predicted: np.array,
sample_weight: typing.Optional[np.array] = None,
labels: typing.Optional[np.array] = None) -> float:
return sklearn.metrics.explained_variance_score(actual, predicted, sample_weight=sample_weight,
multioutput='uniform_average')
You can’t perform that action at this time.