2023-11-05 17:15:11 +01:00
|
|
|
import os
|
|
|
|
import joblib
|
|
|
|
import pandas as pd
|
2023-12-02 19:25:54 +01:00
|
|
|
from sklearn.impute import SimpleImputer
|
2023-11-05 17:15:11 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-12-02 19:25:54 +01:00
|
|
|
imputer = SimpleImputer(strategy='mean')
|
|
|
|
X_imputed = imputer.fit_transform(X_test)
|
|
|
|
|
2023-11-05 17:15:11 +01:00
|
|
|
model_filename = 'trained_model.pkl'
|
|
|
|
model = joblib.load(model_filename)
|
|
|
|
|
|
|
|
predictions = model.predict(X_test)
|
|
|
|
print(predictions)
|
|
|
|
|