pycredits.data_preprocessing

Module Contents

Functions

preprocess_data(df, numeric_features, categorical_features)

Preprocesses the input DataFrame by applying scaling to numeric features and one-hot encoding to categorical features.

pycredits.data_preprocessing.preprocess_data(df, numeric_features, categorical_features)[source]

Preprocesses the input DataFrame by applying scaling to numeric features and one-hot encoding to categorical features.

Parameters:

dfpandas.DataFrame

Input DataFrame.

numeric_featureslist

List of names of numeric features.

categorical_featureslist

List of names of categorical features.

Returns:

tuple

Tuple containing preprocessed features (X_transformed), target variable (y), and preprocessor object (preprocessor).

Examples:

>>> from sklearn.preprocessing import StandardScaler, OneHotEncoder
>>> from sklearn.compose import ColumnTransformer
>>> preprocess_data(df, ["Age", "Credit amount"], ["Status", "Credit history"])