Spaces:
Sleeping
Sleeping
File size: 1,323 Bytes
d8608cd 71ff0bf d8608cd a49ff9c d8608cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import pandas as pd
import numpy as np
import os
from preprocessing.sliding_window import split_sequences_multi_output
from preprocessing.featureEng import FeatureEngineering
from sklearn.preprocessing import MinMaxScaler
from sklearn.decomposition import PCA
from typing import List
class FeatureEngineeringPredict(FeatureEngineering):
'''
Performs feature engineering, including extracting lagged and rolling
window features, and processing the data for machine learning models.
'''
def __init__(self, dataset, fit_pca:PCA, fit_scaler:MinMaxScaler):
super().__init__(dataset)
self._fit_pca = fit_pca
self._fit_scaler = fit_scaler
def process(self, n_steps:int, n_steps_out:int):
'''
scales the data,
formats the sequences for input into time series models.
'''
self._scale()
self._PCA()
X_seq, _, _ = split_sequences_multi_output(self._X, None, n_steps, n_steps_out)
return X_seq
def _scale(self):
'''
Scales the training, validation, and test sets using MinMax scaling.
'''
self._X = self._fit_scaler.transform(self._X)
def _PCA(self):
'''
Reduces dimentionality of data
'''
self._X = self._fit_pca.transform(self._X)
|