Create features/feature_engineering.py
Browse files
features/feature_engineering.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sklearn.preprocessing import StandardScaler
|
| 2 |
+
|
| 3 |
+
def scale_features(X_train, X_test):
|
| 4 |
+
"""
|
| 5 |
+
Scale features using StandardScaler.
|
| 6 |
+
|
| 7 |
+
Args:
|
| 8 |
+
X_train (pd.DataFrame): Training features.
|
| 9 |
+
X_test (pd.DataFrame): Testing features.
|
| 10 |
+
|
| 11 |
+
Returns:
|
| 12 |
+
X_train_scaled, X_test_scaled: Scaled features.
|
| 13 |
+
"""
|
| 14 |
+
scaler = StandardScaler()
|
| 15 |
+
X_train_scaled = scaler.fit_transform(X_train)
|
| 16 |
+
X_test_scaled = scaler.transform(X_test)
|
| 17 |
+
return X_train_scaled, X_test_scaled
|