Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is my code (3 pages continuous code) however, i would like add a 2D PCA to check the separability of the original data, just

this is my code (3 pages continuous code)

image text in transcribed

image text in transcribed

however, i would like add a 2D PCA to check the separability of the original data, just like this

image text in transcribed

need help! Will definitely leave an upvote if i find it helpful. Thank you.

\% Load training data load('ELEC3810_Final_project.mat'); \% Preprocessing \% Remove unreliable data from the training state validIndices = wisnan(trainstate); trainSpike = trainSpike(:, validIndices); trainstate = trainstate(validIndices); \% Feature engineering \% You can experiment with different historical spike counts (lags) \% For simplicity, let's consider only one lag (100 ms) lag=1 X_train = createLaggedMatrix(trainspike, lag); \% Train SVM model svmModel = fitcsum(X_train", trainstate, "KernelFunction ", "linear'); \% Evaluate model performance on training data trainPredictions = predict(svmModel, X_train'); confMatTrain = confusionmat(trainstate, trainPredictions); \% Display confusion matrix for training data disp('Confusion Matrix for Training Data: '); disp(confMatTrain); \% Apply the trained model to test data (testspike) X_test = createLaggedMatrix(testspike, lag); decodedstate = predict(svmModel, X_test'); \% Save the decoding results save('result.mat", "decodedstate"); \% Display an example plot or result figure; plot(decodedstate); % plot the decoded states \% Display confusion matrix for training data disp('Confusion Matrix for Training Data:'); disp(confMatTrain); \% Apply the trained model to test data (testspike) X_test = createLaggedMatrix(testSpike, lag); decodedstate = predict(svmModel, X_test'); I. Save the decoding results save('result.mat", "decodedstate'); \% Display an example plot or result figure; plot(decodedState); \% Plot the decoded states title('Decoded States over Time"); xlabel("Time'); ylabel('Decoded State'); \% Save the figure (if needed) saveas(gcf, 'decoded_states_plot.png'); \% Save the code in main.m save('main.m'); \% Create a report.pdf summarizing your approach \% Include details about preprocessing, parameter exploration, and result \% Save the report in report.pdf \%... \% Function to create lagged matrix function laggedMatrix = createLaggedMatrix(data, lag) laggedMatrix = zeros(size(data, 1) * lag, size(data, 2) - lag + 1); for i=1:lag laggedMatrix((i - 1) * size(data, 1) + 1:i*size(data, 1), :) = end end 2. Check the separability of the original data 2D PCA

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finance The Role Of Data Analytics In Manda Due Diligence

Authors: Ps Publishing

1st Edition

B0CR6SKTQG, 979-8873324675

More Books

Students also viewed these Databases questions