Skip to content

ml_utils

data_splitting(input_x, input_y, split_ratio)

split data into training and testing set

Source code in exe_kg_lib/utils/task_utils/ml_utils.py
17
18
19
20
21
22
23
24
25
26
27
28
29
def data_splitting(
    input_x: pd.DataFrame, input_y: np.ndarray, split_ratio: str
) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame]:
    """split data into training and testing set"""

    splitting_point = int(float(split_ratio) * float(input_x.shape[0]))

    train_x = input_x.iloc[:splitting_point]
    test_x = input_x.iloc[splitting_point:]
    train_y = input_y.iloc[:splitting_point]
    test_y = input_y.iloc[splitting_point:]

    return train_x, test_x, train_y, test_y

Last update: October 20, 2023