def test_first_call(self): trainable_pipeline = StandardScaler() trained_pipeline = trainable_pipeline.fit(self.X_train, self.y_train) new_pipeline = trained_pipeline.freeze_trained() >> SGDClassifier() new_trained_pipeline = new_pipeline.partial_fit(self.X_train, self.y_train, classes=[0, 1, 2]) _ = new_trained_pipeline.predict(self.X_test)
def test_batching_with_hyperopt(self): from lale.lib.lale import Batching, Hyperopt from lale.lib.sklearn import MinMaxScaler, SGDClassifier pipeline = Batching(operator=MinMaxScaler() >> SGDClassifier()) trained = pipeline.auto_configure( self.X_train, self.y_train, optimizer=Hyperopt, max_evals=1 ) _ = trained.predict(self.X_test)
def test_batching_with_hyperopt(self): from lale.lib.sklearn import MinMaxScaler, SGDClassifier from lale.lib.lale import Hyperopt, Batching from sklearn.metrics import accuracy_score pipeline = Batching(operator=MinMaxScaler() >> SGDClassifier()) trained = pipeline.auto_configure(self.X_train, self.y_train, optimizer=Hyperopt, max_evals=1) predictions = trained.predict(self.X_test)
def test_call_on_trainable(self): trainable_pipeline = StandardScaler() trained_pipeline = trainable_pipeline.fit(self.X_train, self.y_train) new_pipeline = trained_pipeline.freeze_trained() >> SGDClassifier() new_pipeline.partial_fit(self.X_train, self.y_train, classes=[0, 1, 2]) new_pipeline.pretty_print() new_trained_pipeline = new_pipeline.partial_fit(self.X_test, self.y_test, classes=[0, 1, 2]) self.assertEqual(new_trained_pipeline, new_pipeline._trained) _ = new_trained_pipeline.predict(self.X_test) new_pipeline.partial_fit(self.X_train, self.y_train, classes=[0, 1, 2])
def test_second_call_with_different_classes_trainable(self): trainable_pipeline = StandardScaler() trained_pipeline = trainable_pipeline.fit(self.X_train, self.y_train) new_pipeline = trained_pipeline.freeze_trained() >> SGDClassifier() new_pipeline.partial_fit(self.X_train, self.y_train, classes=[0, 1, 2]) # Once SGDClassifier is trained, it has a classes_ attribute. self.assertTrue(self._last_impl_has(new_pipeline._trained, "classes_")) subset_labels = self.y_test[np.where(self.y_test != 0)] subset_X = self.X_test[0:len(subset_labels)] new_trained_pipeline = new_pipeline.partial_fit( subset_X, subset_labels) _ = new_trained_pipeline.predict(self.X_test)
def test_second_call_without_classes(self): trainable_pipeline = StandardScaler() trained_pipeline = trainable_pipeline.fit(self.X_train, self.y_train) new_pipeline = trained_pipeline.freeze_trained() >> SGDClassifier() new_trained_pipeline = new_pipeline.partial_fit(self.X_train, self.y_train, classes=[0, 1, 2]) # Once SGDClassifier is trained, it has a classes_ attribute. self.assertTrue(self._last_impl_has(new_trained_pipeline, "classes_")) new_trained_pipeline = new_trained_pipeline.partial_fit( self.X_test, self.y_test) _ = new_trained_pipeline.predict(self.X_test)
def test_sgd_classifier_3(self): from lale.lib.sklearn import SGDClassifier reg = SGDClassifier(l1_ratio=0.2, penalty='l1') reg.fit(self.X_train, self.y_train)
def test_sgd_classifier_2(self): from lale.lib.sklearn import SGDClassifier reg = SGDClassifier(early_stopping=False, validation_fraction=0.2) reg.fit(self.X_train, self.y_train)
def test_sgd_classifier_1(self): from lale.lib.sklearn import SGDClassifier reg = SGDClassifier(learning_rate='optimal', eta0=0.2) reg.fit(self.X_train, self.y_train)
def test_sgd_classifier(self): from lale.lib.sklearn import SGDClassifier reg = SGDClassifier(loss='squared_loss', epsilon=0.2) reg.fit(self.X_train, self.y_train)
def test_sgd_classifier_3(self): reg = SGDClassifier(l1_ratio=0.2, penalty="l1") reg.fit(self.X_train, self.y_train)
def test_sgd_classifier_2(self): reg = SGDClassifier(early_stopping=False, validation_fraction=0.2) reg.fit(self.X_train, self.y_train)
def test_sgd_classifier_1(self): reg = SGDClassifier(learning_rate="optimal", eta0=0.2) reg.fit(self.X_train, self.y_train)
def test_sgd_classifier(self): reg = SGDClassifier(loss="squared_loss", epsilon=0.2) reg.fit(self.X_train, self.y_train)
def test_export_to_sklearn_pipeline5(self): lale_pipeline = PCA() >> (XGBClassifier() | SGDClassifier()) with self.assertRaises(ValueError): _ = lale_pipeline.export_to_sklearn_pipeline()