def fit(self, data_x, data_y, validation_data=None, dataset_split=None, verbose=None): """Fit self-organizing deep learning polynomial neural network :param data_x : numpy array or sparse matrix of shape [n_samples,n_features] training data :param data_y : numpy array of shape [n_samples] target values :return an instance of self. Example of using ---------------- from gmdh import Regressor model = Regressor() model.fit(data_x, data_y) """ if verbose is not None: self.verbose = verbose data_x, data_y = train_preprocessing(data_x, data_y, self.feature_names) if validation_data is None: input_train_x, train_y, input_validate_x, validate_y = split_dataset( data_x, data_y, self.param.seq_type) input_data_x = data_x else: input_validate_x, validate_y = train_preprocessing( validation_data[0], validation_data[1], self.feature_names) input_train_x = data_x train_y = data_y input_data_x = np.vstack((input_train_x, input_validate_x)) data_x = input_data_x data_y = np.hstack((train_y, validate_y)) self.n_features = data_x.shape[1] self.l_count = self.n_features self.n_train = input_train_x.shape[0] self.n_validate = input_validate_x.shape[0] if self.param.normalize: self.scaler = StandardScaler() input_train_x = self.scaler.fit_transform(input_train_x) input_validate_x = self.scaler.transform(input_validate_x) input_data_x = self.scaler.transform(input_data_x) train_y, validate_y, data_y = self._preprocess_y(train_y, validate_y, data_y) fit_data = FitData(input_train_x, train_y, input_validate_x, validate_y, data_x, data_y, input_train_x, input_validate_x, input_data_x) self._pre_fit_check(train_y, validate_y) self._fit(fit_data) return self
def fit(self, data_x, data_y): """ Fit multilayered group method of data handling algorithm (model) Parameters ---------- data_x : numpy array or sparse matrix of shape [n_samples,n_features] training data data_y : numpy array of shape [n_samples] target values Returns ------- self : returns an instance of self. Example of using ---------------- from gmdh import MultilayerGMDH gmdh = MultilayerGMDH() gmdh.fit(data_x, data_y) """ data_x, data_y, self.data_len = train_preprocessing( data_x, data_y, self.feature_names) self.data_y = data_y if self.param.normalize: self.scaler = StandardScaler() self.data_x = self.scaler.fit_transform(data_x) else: self.data_x = data_x self._set_data(self.data_x, self.data_y) self._pre_fit_check() self._train_gmdh() return self