A Package to use pandas DataFrame in sklearn pipeline. And others useful works to use sklearn pipeline in non usual way.
Project description
The main use of this package is to use Sklearn Pipeline with transformer / estimator that doesn't comply with the basic Pipeline:
1 - Use sklearn Pipeline with transformation on Y:
from sklearn_pandas_transformers.transformers import SplitXY, EstimatorWithoutYWrapper, SklearnPandasWrapper
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.impute import KNNImputer
from sklearn.pipeline import Pipeline
import pandas as pd
import numpy as np
input_df = pd.DataFrame([[0, 1, 2, 3], [4, 5, 6, 7], [8, np.nan, 9, 10]])
input_df.columns = ["a", "b", "c", "d"]
spliter = SplitXY("a")
pipe = Pipeline([
("imputer", SklearnPandasWrapper(KNNImputer())),
("spliter", spliter), ("scaler", StandardScaler()),
("rf",
EstimatorWithoutYWrapper(RandomForestRegressor(random_state=45),
spliter))
])
pipe.fit(input_df)
res = pipe.predict(input_df)
2 - Use sklearn Transformer (returning numpy array) to return pandas DataFrame (with unchanged columns names):
SklearnPandasWrapper(StandardScaler()))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sklearn-pandas-transformers-0.0.12.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cc4e596273988a8d6e9e349e09722a64551cc0faf9fc4d6eb03d02f0a444c32 |
|
MD5 | 40944700600bbc9dc2f5239ce1292f24 |
|
BLAKE2b-256 | a0e6938c0a6688b183bf2f17cf3b69ca3f703d7b5c34d6b5843dd930b5f96b60 |
Close
Hashes for sklearn_pandas_transformers-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2283a26bcc3bf1b50bc116f4199916bb5831c57d6f2bbf0e56028e07dc8c74c4 |
|
MD5 | 13cfdb2787179b2acdc65e6a4cf7f2cf |
|
BLAKE2b-256 | b818e4f3d160da36f6e9e78a31b68939ed034970b17818b228a9158be754c059 |