Building machine learning model

2 views (last 30 days)
Hello,
I am having problem in creating machine learning model.
I try to use
fitcknn (), fitctree ()
to build a model.
However the fitcknn gives me some errors that I dont know how to fix.
Here is my code
load timefeat;
train = (time);
a = length(train);
timefeat_t=[];
for sg=1:a
timefeat_t=[timefeat_t, train{1,sg}];
Lengths_T(sg)=length(train{1,sg});
end
X=timefeat_t';
n_obs=size(timefeat_t,2);
y=cell(n_obs,1);
group1=sum(Lengths_T(1:1));
group2=group1+sum(Lengths_T(2:end));
y(1:group1)={'low speed'}; % Class 1 definition - Train
y(group1+1:group2)={'high speed'}; % Class 2 definition - Train
X_Train=X;
Y_Train=y;
T_Train=table(X,y);
Model2_1=fitcknn(T_Train.X,T_Train.y,...
'NumNeighbors',10,'Distance','cityblock');
Model2_2=fitctree(T_Train.X,T_Train.y);
I have included the data file "timefeat.mat"
Could anyone please check my code and help me understand what error did I make and how should i fix it?
Thank you
  1 Comment
keerthana pothula
keerthana pothula on 2 Jun 2021
Machine Learning is a core component of Artificial Intelligence that includes how machines can analyze data, identify patterns and make decisions with low to no human intervention. With the ever-increasing demand for machine automated solutions ML has become one of the rapidly evolving technology along with AI & Data Science.
Find the Latest Machine Learning projects based on ML algorithms for open source machine learning.
Facial Emotion Detection using Neural Networks
Cancer Prediction using Naive Bayes
Tour Recommender App Using Collaborative Filtering
Driver Drowsiness Detection System for Accident Prevention
Automatic Salt Segmentation with UNET in Python using
Deep Learning Transformer Conversational Chatbot in Python using TensorFlow
2.0 Lane-Line Detection System in Python using OpenCV
Facial Emotion Recognition and Detection in Python using Deep Learning
Diabetes Prediction Using Data Mining
Data Mining for Sales Prediction in Tourism Industry
Higher Education Access Prediction
Software Hotel Recommendation System Based on Hybrid Recommendation Model

Sign in to comment.

Accepted Answer

Nipun Katyal
Nipun Katyal on 12 Aug 2020
Hi, as you have only two labels such a large number of neighbours are not required, Instead you can change the distance to 'cosine' and try shuffling the rows. You can find improved result using the configurations below,
Model2_1=fitcknn(T_Train.X,T_Train.y,...
'NumNeighbors',5,'Distance','cosine');
  1 Comment
An Van
An Van on 16 Aug 2020
Thank you, after changing the define, it works

Sign in to comment.

More Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!