99from DashAI .back .dataloaders .classes .dashai_dataset import DashAIDataset
1010from DashAI .back .job .base_job import JobError
1111from DashAI .back .types .dashai_data_type import DashAIDataType
12+ from DashAI .back .types .utils import save_types_in_arrow_metadata
1213
1314
1415class ImbalancedLearnWrapper (BaseConverter , metaclass = ABCMeta ):
1516 """Generic wrapper for imbalanced-learn samplers (e.g., SMOTE, ADASYN)."""
1617
18+ SUPERVISED = True
19+
1720 def __init__ (self , ** kwargs ):
1821 super ().__init__ (** kwargs )
1922 self .fitted = False
@@ -96,6 +99,16 @@ def fit(self, x: DashAIDataset, y: DashAIDataset) -> Type[BaseConverter]:
9699 self ._resampled_table = pa .Table .from_pandas (
97100 combined_df , preserve_index = False
98101 )
102+ combined_types = x .types .copy ()
103+ combined_types .update (y .types )
104+ types_serialized = {
105+ col : combined_types [col ].to_string () for col in combined_types
106+ }
107+
108+ self ._resampled_table = save_types_in_arrow_metadata (
109+ self ._resampled_table , types_serialized
110+ )
111+
99112 except Exception as e :
100113 raise JobError (
101114 f"Failed to prepare resampled data as PyArrow Table: { e } "
@@ -118,7 +131,9 @@ def transform(
118131 y_types = y .types .copy ()
119132 ds_types .update (y_types )
120133 try :
121- dataset = DashAIDataset (self ._resampled_table , types = ds_types , splits = {})
134+ dataset = DashAIDataset (
135+ self ._resampled_table , types = ds_types , splits = x .splits
136+ )
122137 return dataset
123138
124139 except Exception as e :
0 commit comments