neuraxle.union

Union of Features

This module contains steps to perform various feature unions and model stacking, using parallelism is possible.

Classes

AddFeatures(steps_as_tuple, BaseStep], …)

Parallelize the union of many pipeline steps AND concatenate the new features to the received inputs using Identity.

FeatureUnion(steps_as_tuple, BaseStep], …)

Parallelize the union of many pipeline steps.

ModelStacking(steps_as_tuple, BaseStep], …)

Performs a FeatureUnion of steps, and then send the joined result to the above judge step.

class neuraxle.union.AddFeatures(steps_as_tuple: List[Union[Tuple[str, BaseStep], BaseStep]], **kwargs)[source]

Parallelize the union of many pipeline steps AND concatenate the new features to the received inputs using Identity.

pipeline = Pipeline([
    AddFeatures([
        PCA(n_components=2),
        FastICA(n_components=2),
    ])
])
class neuraxle.union.FeatureUnion(steps_as_tuple: List[Union[Tuple[str, BaseStep], BaseStep]], joiner: neuraxle.base.NonFittableMixin = NumpyConcatenateInnerFeatures( name=joiner, hyperparameters=HyperparameterSamples() ), n_jobs: int = None, backend: str = 'threading', cache_folder_when_no_handle: str = None)[source]

Parallelize the union of many pipeline steps.

p = Pipeline([
    FeatureUnion([
        Mean(),
        Std(),
    ], joiner=NumpyConcatenateInnerFeatures())
])

data_inputs = np.random.randint((1, 20))
class neuraxle.union.ModelStacking(steps_as_tuple: List[Union[Tuple[str, BaseStep], BaseStep]], judge: neuraxle.base.BaseStep, **kwargs)[source]

Performs a FeatureUnion of steps, and then send the joined result to the above judge step.

Usage example:

model_stacking = Pipeline([
    ModelStacking([
        SKLearnWrapper(
            GradientBoostingRegressor(),
            HyperparameterSpace({
                "n_estimators": RandInt(50, 600), "max_depth": RandInt(1, 10),
                "learning_rate": LogUniform(0.07, 0.7)
            })
        ),
        SKLearnWrapper(
            KMeans(),
            HyperparameterSpace({
                "n_clusters": RandInt(5, 10)
            })
        ),
    ],
        joiner=NumpyTranspose(),
        judge=SKLearnWrapper(
            Ridge(),
            HyperparameterSpace({
                "alpha": LogUniform(0.7, 1.4),
                "fit_intercept": Boolean()
            })
        ),
    )
])