-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluateModel.m
More file actions
32 lines (23 loc) · 807 Bytes
/
evaluateModel.m
File metadata and controls
32 lines (23 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function evaluateModel(model, X_test, y_test)
% Predict with scores
[y_pred, score] = predict(model, X_test);
% Accuracy
accuracy = sum(y_pred == y_test) / length(y_test);
disp(['Accuracy: ', num2str(accuracy * 100), '%']);
% --- Confidence using softmax ---
expScore = exp(score);
confidenceMatrix = expScore ./ sum(expScore, 2);
confidence = max(confidenceMatrix, [], 2);
% Labels
labels = ["Walking", "Upstairs", "Downstairs", "Sitting", "Standing", "Laying"];
% --- RANDOM SAMPLE DISPLAY ---
disp('Random Sample Predictions:');
idx = randperm(length(y_pred), 10);
for i = 1:10
j = idx(i);
disp(['Prediction: ', char(labels(y_pred(j))), ...
' | Confidence: ', num2str(confidence(j))]);
end
% Confusion matrix
confusionchart(y_test, y_pred);
end