'Fit the model from data in X.
Parameters
X : array-like, shape (n_samples, n_features)
Training vector, where n_samples is the number of samples
and n_features is the number of features.
If affinity is "precomputed"
X : array-like, shape (n_samples, n_samples),
Interpret X as precomputed adjacency graph computed from
samples.
Returns
self : object
Returns the instance itself.'

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

    X = check_array(X, ensure_min_samples=2, estimator=self)
    random_state = check_random_state(self.random_state)
    if isinstance(self.affinity, six.string_types):
        if (self.affinity not in set(('nearest_neighbors', 'rbf', 'precomputed'))):
            raise ValueError(("%s    is    not    a    valid    affinity.    Expected    'precomputed',    'rbf',    'nearest_neighbors'    or    a    callable." % self.affinity))
    elif (not callable(self.affinity)):
        raise ValueError(("'affinity'    is    expected    to    be    an    affinity    name    or    a    callable.    Got:    %s" % self.affinity))
    affinity_matrix = self._get_affinity_matrix(X)
    self.embedding_ = spectral_embedding(affinity_matrix, n_components=self.n_components, eigen_solver=self.eigen_solver, random_state=random_state)
    return self
