Coverage for addmo/s1_data_tuning_auto/data_tuner_auto.py: 78%

32 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2025-08-31 13:05 +0000

1import pandas as pd 

2from addmo.s1_data_tuning_auto.config.data_tuning_auto_config import DataTuningAutoSetup 

3from addmo.util.load_save import load_data 

4from addmo.s1_data_tuning_auto import feature_construction as fc 

5from addmo.s1_data_tuning_auto import feature_selection as fs 

6from addmo.util.data_handling import split_target_features 

7 

8class DataTunerAuto: 

9 """ 

10 This class is used to run the system_data tuning process automatically, possibly leading to 

11 different results depending on the run. 

12 """ 

13 

14 def __init__(self, config: DataTuningAutoSetup): 

15 self.config = config 

16 self.xy_raw = load_data(self.config.abs_path_to_data) 

17 self.x, self.y = split_target_features(self.config.name_of_target, self.xy_raw) 

18 

19 def tune_auto(self): 

20 """ 

21 This method is used to run the system_data tuning process automatically, possibly leading to 

22 different results depending on the run. 

23 """ 

24 self.feature_construction() 

25 self.feature_selection() 

26 return self.x 

27 

28 def feature_construction(self): 

29 """ 

30 This method is used to construct new features from the raw system_data. 

31 """ 

32 if self.config.create_differences: 

33 x_created = fc.create_difference(self.config, self.xy_raw) 

34 self.x = pd.concat([self.x, x_created], axis=1, join="inner").bfill() 

35 if self.config.create_manual_target_lag: 

36 x_created = fc.manual_target_lags(self.config, self.xy_raw) 

37 self.x = pd.concat([self.x, x_created], axis=1, join="inner").bfill() 

38 if self.config.create_manual_feature_lags: 

39 x_created = fc.manual_feature_lags(self.config, self.xy_raw) 

40 self.x = pd.concat([self.x, x_created], axis=1, join="inner").bfill() 

41 

42 

43 

44 def feature_selection(self): 

45 """ 

46 This method is used to select features from the raw system_data. 

47 """ 

48 if self.config.manual_feature_selection: 

49 self.x = fs.manual_feature_select(self.config, self.x) 

50 

51 if self.config.filter_recursive_by_count: 

52 self.x = fs.recursive_feature_selection_by_count(self.config, self.x, self.y) 

53 

54 if self.config.filter_recursive_by_score: 

55 self.x = fs.recursive_feature_selection_by_score(self.config, self.x, self.y) 

56