From 12b7f178382717b5b1b8f7a25f2dea5853832d59 Mon Sep 17 00:00:00 2001 From: ilydzi Date: Sun, 5 Nov 2023 17:15:11 +0100 Subject: [PATCH] Added model inference script --- machine_learning/model_inference.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 machine_learning/model_inference.py diff --git a/machine_learning/model_inference.py b/machine_learning/model_inference.py new file mode 100644 index 0000000..46b4e9a --- /dev/null +++ b/machine_learning/model_inference.py @@ -0,0 +1,23 @@ +import os +import joblib +import pandas as pd + +TEST_DATA_DIR = "datasets_test" + +test_df_list = [] +for file in os.listdir(TEST_DATA_DIR): + file_path = os.path.join(TEST_DATA_DIR, file) + df = pd.read_csv(file_path, delim_whitespace=True, skiprows=1, + names=["tbid", "tphys", "r", "vr", "vt", "ik1", "ik2", "sm1", "sm2", "a", "e", + "collapsed"]) + test_df_list.append(df) + +data_test = pd.concat(test_df_list, ignore_index=True).sample(frac=1, random_state=42) +X_test = data_test.iloc[:, 1:-1].values + +model_filename = 'trained_model.pkl' +model = joblib.load(model_filename) + +predictions = model.predict(X_test) +print(predictions) +