-
Notifications
You must be signed in to change notification settings - Fork 19
Some bugs in the code #16
Description
Thank you authors for this great work! My version of pm4py==2.7.12.4, then I tried the demo, I found several issues:
- In the ocpa/algo/enhancement/token_replay_based_performance/util.py
change the code:
import pm4py.evaluation.replay_fitness.variants.token_replay as tb_replay
To
import pm4py.algo.evaluation.replay_fitness.variants.token_replay as tb_replay
- For the last demo for preprocessing and prediction, it should be:
from ocpa.util.util import LinearRegression
from ocpa.util.util import mean_absolute_error
from ocpa.objects.log.importer.ocel import factory as ocel_import_factory
from ocpa.algo.predictive_monitoring import factory as predictive_monitoring
from ocpa.algo.predictive_monitoring import tabular
from sklearn.preprocessing import MinMaxScaler
filename = "sample_logs/jsonocel/p2p-normal.jsonocel"
ocel = ocel_import_factory.apply(filename)
activities = list(set(ocel.log.log["event_activity"].tolist()))
feature_set = [(predictive_monitoring.EVENT_REMAINING_TIME, ()),
(predictive_monitoring.EVENT_PREVIOUS_TYPE_COUNT, ("GDSRCPT",)),
(predictive_monitoring.EVENT_ELAPSED_TIME, ())] +
[(predictive_monitoring.EVENT_PRECEDING_ACTIVITIES, (act,)) for act in activities]
feature_storage = predictive_monitoring.apply(ocel, feature_set, [])
feature_storage.extract_normalized_train_test_split(scaler = MinMaxScaler, test_size=0.3, state = 3395)
train_table = tabular.construct_table(
feature_storage, index_list=feature_storage._train_indices)
test_table = tabular.construct_table(
feature_storage, index_list=feature_storage._test_indices)
y_train, y_test = train_table[feature_set[0]], test_table[feature_set[0]]
x_train_, x_test_ = train_table.drop(
feature_set[0], axis=1), test_table.drop(feature_set[0], axis=1)
x_train = x_train_.loc[:, ~(x_train_ == 0).all()]
x_test = x_test_.loc[:, ~(x_train_ == 0).all()]
model = LinearRegression()
model.fit(x_train, y_train)
y_pred = model.predict(x_test)
avg_rem = sum(y_train)/len(y_train)
print('MAE baseline: ', mean_absolute_error(
y_test, [avg_rem for elem in y_test]))
print('MAE: ', mean_absolute_error(y_test, y_pred))`