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
File details
Details for the file sklearn-pandas-transformers-0.0.12.tar.gz
.
File metadata
- Download URL: sklearn-pandas-transformers-0.0.12.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cc4e596273988a8d6e9e349e09722a64551cc0faf9fc4d6eb03d02f0a444c32 |
|
MD5 | 40944700600bbc9dc2f5239ce1292f24 |
|
BLAKE2b-256 | a0e6938c0a6688b183bf2f17cf3b69ca3f703d7b5c34d6b5843dd930b5f96b60 |
File details
Details for the file sklearn_pandas_transformers-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: sklearn_pandas_transformers-0.0.12-py3-none-any.whl
- Upload date:
- Size: 1.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2283a26bcc3bf1b50bc116f4199916bb5831c57d6f2bbf0e56028e07dc8c74c4 |
|
MD5 | 13cfdb2787179b2acdc65e6a4cf7f2cf |
|
BLAKE2b-256 | b818e4f3d160da36f6e9e78a31b68939ed034970b17818b228a9158be754c059 |