def fit(self, X, y):
"""
Fit on X.
:param X: {array-like, sparse matrix}, shape (n_samples, n_features). Input data, where `n_samples` is the
number of samples and `n_features` is the number of features.
:return: Returns self
"""
# Numpy
X = np.array(X)
y = np.array(y)
# Check that X and y have correct shape
X, y = check_X_y(X, y)
# Store the classes seen during fit
self.classes_ = unique_labels(y)
# Store so that we know what we fitted on
self.X_ = X
self.y_ = y
# Get dimensions
input_dim = X.shape[1]
output_dim = len(self.classes_)
# Create a model if needed
if (input_dim, output_dim) != self.io:
self.model = self._build(input_dim, output_dim)
self.model.fit(X, y, batch_size=self.batch_size, epochs=self.epochs, verbose=self.verbose)
# Return the classifier
return self
评论列表
文章目录