def test_multimodal(self): from lale.lib.lale import ConcatFeatures as Cat from lale.lib.lale import Project from lale.lib.sklearn import LinearSVC from lale.lib.sklearn import Normalizer as Norm from lale.lib.sklearn import OneHotEncoder as OneHot project_0 = Project(columns={"type": "number"}) project_1 = Project(columns={"type": "string"}) linear_svc = LinearSVC(C=29617.4, dual=False, tol=0.005266) pipeline = ( ((project_0 >> Norm()) & (project_1 >> OneHot())) >> Cat >> linear_svc ) expected = """from lale.lib.lale import Project from sklearn.preprocessing import Normalizer as Norm from sklearn.preprocessing import OneHotEncoder as OneHot from lale.lib.lale import ConcatFeatures as Cat from sklearn.svm import LinearSVC import lale lale.wrap_imported_operators() project_0 = Project(columns={"type": "number"}) project_1 = Project(columns={"type": "string"}) linear_svc = LinearSVC(C=29617.4, dual=False, tol=0.005266) pipeline = ( ((project_0 >> Norm()) & (project_1 >> OneHot())) >> Cat >> linear_svc )""" self._roundtrip(expected, lale.pretty_print.to_string(pipeline))
def test_multiple_estimators_predict_predict_proba(self): pipeline = (StandardScaler() >> (LogisticRegression() & PCA()) >> ConcatFeatures() >> (NoOp() & LinearSVC()) >> ConcatFeatures() >> KNeighborsClassifier()) pipeline.fit(self.X_train, self.y_train) _ = pipeline.predict_proba(self.X_test) _ = pipeline.predict(self.X_test)