Two codes for the same dataset have different root mean square error values
2 views (last 30 days)
Show older comments
Hello, i am working on wknn for localization, the first code requires input of the rss values and the error is less than 5m but the second code has a training and a test set and the error is above 500m, i cannot figure why this is happening. I have attached the code and the dataset. Thank you.
0 Comments
Answers (1)
Drishti
on 1 Oct 2024
Hi Chinaza,
On reproducing the code on my end, I encountered a similar issue ‘error value exceeding 500’ for file named ‘havershinewknntest’.
The file 'wknntestwithinput' localizes a single point, which is not a recommended method for assessing performance and calculating errors. On the other hand, the 'havershinewknntest' file employs an iterative method throughout the dataset, providing enhancements over the initial code.
The ‘havershinewknntest’ approach can be improved by utilizing techniques like normalization of RSS values and distributing dataset in robust manner.
You can refer to the below code snippet to get an overview of the same.
% Normalize the RSS values (feature scaling)
rss_values = (rss_values - mean(rss_values)) ./ std(rss_values);
% Split data into training and testing sets
train_ratio = 0.7;
Additionally, you can also utilize the ‘cvpartition’ function for partioning data for cross-validation.
Refer to the implementation below:
% Create a cross-validation partition object
cv = cvpartition(n_train, 'KFold', 5);
Refer to the MATLAB Documentation of the ‘cvpartition’ function:
I hope this helps.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!