Matlab - Modelformed.NumNeighbors
조회 수: 3 (최근 30일)
이전 댓글 표시
Mustafa Furkan SAHIN
2022년 12월 16일
댓글: Mustafa Furkan SAHIN
2022년 12월 17일
What should NumNeighbors be equal to so I can find the correct result? How is NumNeighbors determined?
I tried all the values, but some outputs show correct and then incorrect responses.
I have a Higher Education Students Performance Evaluation Dataset (145rows and 32columns)
opts = delimitedTextImportOptions("NumVariables", 32);
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
opts.VariableNames = ["Q1", "Q2", "Q3", "Q4", "Q5", "Q6","Q7","Q8","Q9","Q10","Q11","Q12","Q13","Q14","Q15","Q16","Q17","Q18","Q19","Q20","Q21","Q22","Q23","Q24","Q25","Q26","Q27","Q28","Q29","Q30","Q31","Output"];
opts.VariableTypes = ["double", "double", "double", "double", "double","double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double" "categorical"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
opts = setvaropts(opts, "Output", "EmptyFieldRule", "auto");
DATASET = readtable("HESPENUMERICDATAwithCategory.data", opts);
clear opts
modelformed = fitcknn(DATASET,'Output~Q1+Q2+Q3+Q4+Q5+Q6+Q7+Q8+Q9+Q10+Q11+Q12+Q13+Q14+Q15+Q16+Q17+Q18+Q19+Q20+Q21+Q22+Q23+Q24+Q25+Q26+Q27+Q28+Q29+Q30+Q31');
modelformed.NumNeighbors=31;
a1=input('Enter Student Age: ');
a2=input('Enter Sex: ');
a3=input('Enter Graduated high-school type: ');
a4=input('Enter Scholarship type: ');
a5=input('Enter Additional work: ');
a6=input('Enter Regular artistic or sports activity: ');
a7=input('Enter Do you have a partner: ');
a8=input('Enter Total salary if available: ');
a9=input('Enter Transportation to the university: ');
a10=input('Enter Accommodation type in Cyprus: ');
a11=input('Enter Mother education: ');
a12=input('Enter Father education: ');
a13=input('Enter Number of sisters/brothers (if available): ');
a14=input('Enter Parental status: ');
a15=input('Enter Mother occupation: ');
a16=input('Enter Father occupation: ');
a17=input('Enter Weekly study hours: ');
a18=input('Enter Reading frequency (non-scientific books/journals): ');
a19=input('Enter Reading frequency (scientific books/journals): ');
a20=input('Enter Attendance to the seminars/conferences related to the department: ');
a21=input('Enter Impact of your projects/activities on your success: ');
a22=input('Enter Attendance to classes: ');
a23=input('Enter Preparation to midterm exams 1: ');
a24=input('Enter Preparation to midterm exams 2: ');
a25=input('Enter Taking notes in classes: ');
a26=input('Enter Listening in classes: ');
a27=input('Enter Discussion improves my interest and success in the course: ');
a28=input('Enter Flip-classroom: ');
a29=input('Enter Cumulative grade point average in the last semester (/4.00): ');
a30=input('Enter Expected Cumulative grade point average in the graduation (/4.00): ');
a31=input('Enter Course ID: ');
predict(modelformed,[a1,a1,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31])
댓글 수: 4
Walter Roberson
2022년 12월 16일
As an outside observer (especially one who does not have access to your data), I have no reason to expect that getting 100% accuracy is even possible
채택된 답변
Walter Roberson
2022년 12월 16일
Your data has 145 rows. You can create a loop from 1 to (145-1)=144 neighbours, asking to predict with each of those number of neighbours in turn, and stopping as soon as you get 100% accuracy.
Hypothetically, accuracy might perhaps increase for a while as number of neighbours is increased, but then perhaps it would decrease. Or perhaps it would more or less reach a stable state, with more neighbours not making any difference. You should investigate.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!