Although it is still a question whether stock price is predictable form previous data, it does not decrease the interest of geeks to predict stock price. Machine Learning is an interesting approach to do the black-box thing. This tutorial will build a predictor to help analysis stock, and even for buying-analysis. Highlights

• Machine Learning Modeling
• Auto-Model Fitting
• Predict Download the package https://www.mathworks.com/matlabcentral/fileexchange/68637-machine-learning-classification-used-to-predict-stock Get Data In order to get previous data, call the following functions. In this tutorial, we are interested in the famous company, "` Data = getMarketDataViaYahoo(‘AAPL', ‘1-July-2013', ‘31-July-2018'); Data Data = 1280×7 table Date Open High Low Close AdjClose Volume ___________ ______ ______ ______ ______ ________ __________ 01-Jul-2013 57.527 58.896 57.317 58.46 52.313 9.7763e+07 02-Jul-2013 58.566 60.233 58.496 59.784 53.498 1.1747e+08 03-Jul-2013 60.123 60.426 59.636 60.114 53.793 6.0232e+07 "` Illustrate the Data To get a rough idea of the stock prices, we will plot the data.
`%Ensure the data is in correct data typeif isnumeric(Data.Open) == falseOpen =cellfun(@str2double,Data.Open);High = cellfun(@str2double,Data.High);Low = cellfun(@str2double,Data.Low);Close = cellfun(@str2double,Data.Close);AdjustedClose = cellfun(@str2double,Data.AdjClose);Volume = cellfun(@str2double,Data.Volume);elseOpen = Data.Open;High = Data.High;Low = Data.Low;Close = Data.Close;AdjustedClose = Data.AdjClose;Volume = Data.Volume;endDate = Data.Date;%Tranform the data to timetableData_TimeTable = timetable(Date,Open,High,Low,Close,Volume);%Check for missing Data%Fill the missing data with linearif any(any(ismissing(Data_TimeTable)))==trueData_TimeTable = fillmissing(Data_TimeTable,'linear');end%Delete the row if volume is 0Data_TimeTable(Data_TimeTable.Volume==0,:) =[];%View the dataplot(Data_TimeTable.Date,Data_TimeTable.Close);title('Air Asia Berhad Stock Price from Jul2013 to Jul2018');ylabel('SGD');xlabel('Timeline');grid on` Select Feature TOBO Continue