Esempio n. 1
0
    def test_autoai_libs_tam_1(self):
        import autoai_libs.cognito.transforms.transform_extras
        import numpy as np
        from autoai_libs.cognito.transforms.transform_utils import TAM

        from lale.lib.sklearn import LogisticRegression as LR

        tam = TAM(
            tans_class=autoai_libs.cognito.transforms.transform_extras.IsolationForestAnomaly,
            name="isoforestanomaly",
            col_names=["a", "b", "c"],
            col_dtypes=[np.dtype("float32"), np.dtype("float32"), np.dtype("float32")],
        )
        pipeline = tam >> LR()
        expected = """from autoai_libs.cognito.transforms.transform_utils import TAM
import autoai_libs.cognito.transforms.transform_extras
import numpy as np
from sklearn.linear_model import LogisticRegression as LR
from sklearn.pipeline import make_pipeline

tam = TAM(
    tans_class=autoai_libs.cognito.transforms.transform_extras.IsolationForestAnomaly,
    name="isoforestanomaly",
    col_names=["a", "b", "c"],
    col_dtypes=[
        np.dtype("float32"), np.dtype("float32"), np.dtype("float32"),
    ],
)
pipeline = make_pipeline(tam, LR())"""
        self._roundtrip(
            expected, lale.pretty_print.to_string(pipeline, astype="sklearn")
        )
Esempio n. 2
0
    def test_autoai_libs_tam_1(self):
        from autoai_libs.cognito.transforms.transform_utils import TAM
        import autoai_libs.cognito.transforms.transform_extras
        import numpy as np
        from lale.lib.sklearn import LogisticRegression as LR
        tam = TAM(tans_class=autoai_libs.cognito.transforms.transform_extras.
                  IsolationForestAnomaly,
                  name='isoforestanomaly',
                  col_names=['a', 'b', 'c'],
                  col_dtypes=[
                      np.dtype('float32'),
                      np.dtype('float32'),
                      np.dtype('float32')
                  ])
        pipeline = tam >> LR()
        expected = \
"""from autoai_libs.cognito.transforms.transform_utils import TAM
import autoai_libs.cognito.transforms.transform_extras
import numpy as np
from lale.lib.sklearn import LogisticRegression as LR
import lale
lale.wrap_imported_operators()

tam = TAM(tans_class=autoai_libs.cognito.transforms.transform_extras.IsolationForestAnomaly, name='isoforestanomaly', col_names=['a', 'b', 'c'], col_dtypes=[np.dtype('float32'), np.dtype('float32'), np.dtype('float32')])
pipeline = tam >> LR()"""
        self._roundtrip(expected, lale.pretty_print.to_string(pipeline))
Esempio n. 3
0
    def test_autoai_libs_tam_2(self):
        from lale.lib.autoai_libs import TAM
        import numpy as np
        from lightgbm import LGBMClassifier
        from sklearn.decomposition import PCA
        from lale.operators import make_pipeline
        pca = PCA(copy=False)
        tam = TAM(tans_class=pca,
                  name='pca',
                  col_names=['a', 'b', 'c'],
                  col_dtypes=[
                      np.dtype('float32'),
                      np.dtype('float32'),
                      np.dtype('float32')
                  ])
        lgbm_classifier = LGBMClassifier(class_weight='balanced',
                                         learning_rate=0.18)
        pipeline = make_pipeline(tam, lgbm_classifier)
        expected = \
"""from lale.lib.autoai_libs import TAM
import sklearn.decomposition.pca
import numpy as np
from lightgbm import LGBMClassifier
from lale.operators import make_pipeline

tam = TAM(tans_class=sklearn.decomposition.pca.PCA(copy=False, iterated_power='auto', n_components=None, random_state=None,   svd_solver='auto', tol=0.0, whiten=False), name='pca', col_names=['a', 'b', 'c'], col_dtypes=[np.dtype('float32'), np.dtype('float32'), np.dtype('float32')])
lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18)
pipeline = make_pipeline(tam, lgbm_classifier)"""
        self._roundtrip(
            expected, lale.pretty_print.to_string(pipeline, combinators=False))
Esempio n. 4
0
    def test_autoai_libs_tam_2(self):
        from lale.lib.autoai_libs import TAM
        import numpy as np
        from lightgbm import LGBMClassifier
        from sklearn.decomposition import PCA
        from lale.operators import make_pipeline
        pca = PCA(copy=False)
        tam = TAM(tans_class=pca, name='pca', col_names=['a', 'b', 'c'], col_dtypes=[np.dtype('float32'), np.dtype('float32'), np.dtype('float32')])
        lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18)
        pipeline = make_pipeline(tam, lgbm_classifier)
        expected = """from autoai_libs.cognito.transforms.transform_utils import TAM
import sklearn.decomposition
import numpy as np
from lightgbm import LGBMClassifier
from lale.operators import make_pipeline

tam = TAM(
    tans_class=sklearn.decomposition.PCA(copy=False),
    name="pca",
    col_names=["a", "b", "c"],
    col_dtypes=[
        np.dtype("float32"),
        np.dtype("float32"),
        np.dtype("float32"),
    ],
)
lgbm_classifier = LGBMClassifier(class_weight="balanced", learning_rate=0.18)
pipeline = make_pipeline(tam, lgbm_classifier)"""
        self._roundtrip(expected, lale.pretty_print.to_string(pipeline, combinators=False))