Skip to content

Commit

Permalink
FIX KernelRidge checks if fitted before predict
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Hendrik Metzen authored and mblondel committed Jan 18, 2015
1 parent 7223efd commit 2a2e7c6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sklearn/kernel_ridge.py
Expand Up @@ -13,6 +13,7 @@
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.linear_model.ridge import _solve_cholesky_kernel
from sklearn.utils.validation import NotFittedError, check_is_fitted


class KernelRidge(BaseEstimator, RegressorMixin):
Expand Down Expand Up @@ -178,5 +179,6 @@ def predict(self, X):
C : array, shape = [n_samples] or [n_samples, n_targets]
Returns predicted values.
"""
check_is_fitted(self, ["X_fit_", "dual_coef_"])
K = self._get_kernel(X, self.X_fit_)
return np.dot(K, self.dual_coef_)

0 comments on commit 2a2e7c6

Please sign in to comment.