Knn code to compare two excel sheet
조회 수: 2 (최근 30일)
이전 댓글 표시
we are working on a power system on which we have to determine whether the failure of the power system is a fault or not a fault. We have created a dataset with all possibilities of faults and not faults of the system called training set. we have created another excel sheet called the training set in which we have taken some values of faults and not faults from the dataset. We want to use knn algorithm and euclidean distance to compare/classify whether the readings in the training set are the values of faults or not faults when compared with the original dataset. As we are putting four five values in the training set, how do we make matlab read and classify all the values one after the other without manually entering the values
P.S- 1 represents 'fault' and 2 represents 'not a fault' (in the AE column of the excel sheet)in the dataset excel sheet. After running knn algorithm we want 1 or 2 displayed on command line and written on training set.
댓글 수: 1
Rik
2017년 3월 23일
You mean you need to read the Excel files into Matlab? That can be done with xlsread. It sounds like after that it is only a few matrix multiplications. (potentially useful function: repmat, also keep in mind that Matlab trims the result from xlsread, removing empty rows and columns)
답변 (1개)
sam CP
2017년 3월 26일
편집: per isakson
2017년 4월 2일
%The following code will helps you.
clc
clear all
training0 = xlsread('training set.xls');
training1 = xlsread('dataset.xlsx');
zero = zeros(10,1);
one = ones(10,1);
group = [zero;one];
test = TestFeatinputMRI;
training = [training0;training1];
KNN = fitcknn(training,group)
Class = knnclassify(test,training,group)
댓글 수: 8
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!