'Fit Kernel Ridge regression model
Parameters
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Training data
y : array-like, shape = [n_samples] or [n_samples, n_targets]
Target values
sample_weight : float or array-like of shape [n_samples]
Individual weights for each sample, ignored if None is passed.
Returns
self : returns an instance of self.'

def fit(self, X, y=None, sample_weight=None):

    (X, y) = check_X_y(X, y, accept_sparse=('csr', 'csc'), multi_output=True, y_numeric=True)
    if ((sample_weight is not None) and (not isinstance(sample_weight, float))):
        sample_weight = check_array(sample_weight, ensure_2d=False)
    K = self._get_kernel(X)
    alpha = np.atleast_1d(self.alpha)
    ravel = False
    if (len(y.shape) == 1):
        y = y.reshape((-1), 1)
        ravel = True
    copy = (self.kernel == 'precomputed')
    self.dual_coef_ = _solve_cholesky_kernel(K, y, alpha, sample_weight, copy)
    if ravel:
        self.dual_coef_ = self.dual_coef_.ravel()
    self.X_fit_ = X
    return self
