I've a dataset as follows:
| idx | Giorno | Ora | Utente | Client | Tipo | Menu | Azienda | daMenu | aMenu |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 10/01/22 | 10:29:46.889 | ADMIN | iDesk | Utente | MD | UBI | mx01.exe | mx23.exe |
| 1 | 10/01/22 | 10:33:52.719 | ADMIN | iDesk | Serv-L | MA | UBI | mx01.exe | mx23.exe |
| 2 | 10/01/22 | 10:48:13.930 | ADMIN | iDesk | Serv-L | MA | UBI | mx00.exe | mx03.exe |
| 3 | 10/01/22 | 10:52:56.899 | ADMIN | iDesk | Serv-L | ZCNH | UBI | mx00.exe | mx03.exe |
| 4 | 10/01/22 | 10:53:42.530 | ADMIN | iDesk | Serv-L | ZP | UBI | mx00.exe | mx302.exe |
| ..... |
This dataset is taken from our management softewer log and shows which menu the user access during time (daMenu is the previous menu, aMenu is the destination menu). The original log has many other fields, but i've made a selection of those, in my opinion, are strictly corrallated to the user and the menu in which is moving to.
The goal is to use this dataset to predict in which menu the user will probably intend to move to. After converting the dataset in numbers with python sklearn LabelEncoder, i've tried some machine learning approach using time series model (DecisionTreeRegressor and RandomForestRegressor) but with poor results. I've taken aMenu as the variable to predict (y) and all the other as features (X), i've then splitted the dataset in Train and Values.
This is the code i use for prediction:
y = df.aMenu_enc
# caratteristiche da usare per la previsione
feat = ['Giorno_enc','Ora_enc','Utente_enc','Client_enc','Tipo_enc','daMenu_enc','Azienda_enc']
X = df[feat]
#print(X.describe())
#print(X.head())
train_X, val_X, train_y, val_y = train_test_split(X,y,random_state=0,test_size=0.10)
modello = DecisionTreeRegressor(max_leaf_nodes=5000,random_state=1)
#modello = RandomForestRegressor(random_state=1)
print("Adesso fitto")
modello.fit(train_X,train_y)
# test
dft = pd.DataFrame()
dft['Giorno_enc'] = LabelEncoder().fit_transform(["13/11/22"])
dft['Ora_enc'] =LabelEncoder().fit_transform(["15:22:31.333"])
dft['Utente_enc'] = LabelEncoder().fit_transform(["GIANLU"])
dft['Client_enc'] = LabelEncoder().fit_transform(["iDesk"])
dft['Tipo_enc'] = LabelEncoder().fit_transform(["Utente"])
dft['daMenu_enc'] = LabelEncoder().fit_transform(["mx23.exe"])
dft['Azienda_enc'] = LabelEncoder().fit_transform(["BIK"])
predizione_aMenu1 = modello.predict(val_X)
predizione_aMenu2 = modello.predict(dft)
print("Errore aassoluto medio MAE: {}".format(mean_absolute_error(val_y,predizione_aMenu1)))
print("Predizione enc: {}".format(predizione_aMenu2))
print("Predizione: {}".format(le_aMenu.inverse_transform(predizione_aMenu2.astype(int))))
print(qualityRes(val_y,predizione_aMenu1))
and this is the output
[1778 rows x 9 columns]
Errore aassoluto medio MAE: 12.898876404494382
Predizione enc: [50.]
Predizione: ['ZCC(mx50.exe)']
Preciso al 37.1%
How can i get best results? Thank you