SlideShare a Scribd company logo
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
Stock Market Trend PredictionUsing K-Nearest
Neighbor(KNN) Algorithm
In this paper author is evaluating performance of KNN(K-Nearest Neighbor)
supervised machine learning algorithm. In the finance world stocktrading is one
of the most important activities. Stock market prediction is an act of trying to
determine the future value of a stock other financial instrument traded on a
financial exchange. The programming language is used to predict the stock
market using machine learning is Python. In this paper we propose a Machine
Learning (ML) approach that will be trained from the available stocks data and
gain intelligence and then uses the acquired knowledge foran accurate prediction.
In this context this study uses a machine learning technique called K-Nearest
Neighbor to predict stockprices for the large and small capitalizations and in the
three different markets, employing prices with both daily and up-to-the-minute
frequencies.
Predicting the Stock Market has been the bane and goal of investors since its
existence. Everyday billions of dollars are traded on the exchange, and behind
each dollar is an investor hoping to profit in oneway oranother. Entire companies
rise and fall daily based on the behaviour of the market. Should an investor be
able to accurately predict market movements, it offers a tantalizing promises of
wealth and influence. It is no wonderthen that the StockMarket and its associated
challenges find their way into the public imagination every time it misbehaves.
The 2008 financial crisis was no different, as evidenced by the flood of films and
documentaries based on the crash. If there was a common theme among those
productions, it was that few people knew how the market worked or reacted.
Perhaps a better understanding of stockmarket prediction might help in the case
of similar events in the future.
Despite its prevalence, StockMarket prediction remains a secretive and empirical
art. Few people, if any, are willing to share what successfulstrategies they have.
A chief goal of this project is to add to the academic understanding of stock
market prediction. The hope is that with a greater understanding of how the
market moves, investors will be better equipped to prevent another financial
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
crisis. The projectwill evaluate someexisting strategies from a rigorous scientific
perspective and provide a quantitative evaluation of new strategies.
There are several data mining algorithms that can be used for prediction purposes
in the field of finance. Some examples would be the naive Bayes classifier, the k
nearest neighbour (KNN) algorithm and the classification and the regression tree
algorithm (Wu et al. 2007). All the mentioned algorithms could fill the purpose
ofthe paper butit will center around the kNN algorithm as a method ofpredicting
stock market movements as well as the MA formula. The movements will be
detected by looking at a large amount of historical data and finding patterns to
establish a well estimated forecast. This specific algorithm was chosen as it is a
simple but a very effective algorithm to implement when looking at large amounts
of data (Berson et al. 1999).The KNN algorithm simply states: "Objects that are
’near’ to each other will have similar prediction values as well. Thus if you know
the prediction value of one of the objects you can predict it for its nearest
neighbours" (Berson et al. 1999). As a comparison with the KNN algorithm, the
MA formula was chosen. The MA formula has its simplicity as a commonfactor
with the KNN algorithm, but it is a statistical method used frequently by traders
(Interactive Data Corp, 2014).
There are existing techniques when it comes to stock prediction, some of them
are multispectral prediction, distortion controlled prediction and lempel-ziv based
prediction. These are based on the fact that the data representation is more
compact by removing redundancy while the essential information is kept in
format that is accessible (Azhar et al. 1994). Due to the scope of the project the
techniques that were the most suitable to work with were the KNN algorithm and
the MA formula despite the existing techniques listed above.
To conductexperiment author has used Yahoo Finance stock Dataset and below
is some example records of that dataset which contains request signatures. I have
also used same dataset and this dataset is available inside ‘dataset’ folder.
Dataset example
['High', 'Low', 'Open', 'Close', 'Volume', 'Adj Close']
Above list are the columns of Yahoo finance
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
201
7-
01-
05
116.8600
01
115.8099
98
115.9199
98
116.6100
01
22193600
.0
111.3933
03
201
7-
01-
09
119.4300
00
117.9400
02
117.9499
97
118.9899
98
33561900
.0
113.6668
24
Above two records are the APPLE stock form the Yahoo Finance Dataset. For
the rest of analysis, we will use the Closing Price which remarks the final price in
which the stocks are traded by the end of the day.
we analyse stocks using two key measurements: Rolling Mean and Return Rate
Rolling Mean:
Rolling mean/Moving Average (MA) smooths out price data by creating a
constantly updated average price. This is useful to cut down “noise” in our price
chart. Furthermore, this Moving Average could act as “Resistance” meaning from
the downtrend and uptrend of stocks you could expect it will follow the trend and
less likely to deviate outside its resistance point.
The Moving Average makes the line smooth and showcase the increasing or
decreasing trend of stocks price.
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
ReturnDeviation— to determineriskandreturn
Expected Return measuresthe mean, or expected value, of the probability
distribution of investment returns. Theexpected return of a portfolio is
calculated by multiplying theweight of each asset by its expected return and
addingthevalues for each investment — Investopedia.
Following is the formula you could refer to:
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
Before running code execute below two commands
Screen shots
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
Double click on ‘run.bat’ file to get below screen
In above screen click on ‘Download Button’ download the Apple Stock and
competitors data from Yahoo Finance Dataset
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
In above screen I am Downloading of Apple Stock and Apple competitor Stock
Data from Yahoo Finance Dataset.
Now click on ‘Correlation Data’ Button to find the correlation between Apple
and Competitor Stock market Dataset. show the trend in the technology industry
rather than show how competing stocks affect each other.
Now click on‘Data PreProcessingbutton to drop missing values, split labels split
train and test
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
After pre-processing all missing values are dropped, Separating the label here,
Scalling of X, find Data Series of late X and early X (train) for model generation
and evaluation, Separatelabeland identifyit as y and Separationof training and
testing of model.
In above screen we can see dataset contains total 1752 records and 1226 used for
training and 526 used for testing.
Now click on ‘Run KNN with Uniform Weights’ to generate KNN model with
uniform weights and calculate its model accuracy
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
In above screen we can see with KNN with uniform weights got 96.8% accuracy,
now click on ‘Run KNN with distance weights’ to calculate accuracy
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
In above screen we got 100% accuracy, now we will click on ‘Predict Test
Data’button to upload test data and to predict whether test data stockmarket for
both models.
accuracy score (>0.95) for most of the models.
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
In above screenfor each test data we got forecastvalues for Apple Stock for each
test record. Now click on ‘KNN Accuracy’ button to save the predicted values
for each model save in the local directory and Accuracy comparison to both the
models
From above graph we can see that distance weights has little bit better better
accuracy compare to Uniform weights, in above graph x-axis contains algorithm
name and y-axis represents accuracy of that algorithms
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
Plotting the PredictionforKNN withUniformWeights:
Venkat Java Projects
Mobile:+91 9966499110
Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com
Plotting the PredictionforKNN withDistanceWeights:

More Related Content

DOCX
Stock market trend prediction using k nearest neighbor(knn) algorithm
PPT
Econometrics and business forecasting
PDF
STOCK MARKET PREDICTION USING MACHINE LEARNING METHODS
PPTX
SAMPLE PPT PRESENTATION FOR REVIEW-1.pptx
PDF
IRJET - Company’s Stock Price Predictor using Machine Learning
PPTX
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
PDF
IRJET - Stock Market Prediction using Machine Learning Algorithm
PPTX
updated stock market ppt.pptx stock market presentation
Stock market trend prediction using k nearest neighbor(knn) algorithm
Econometrics and business forecasting
STOCK MARKET PREDICTION USING MACHINE LEARNING METHODS
SAMPLE PPT PRESENTATION FOR REVIEW-1.pptx
IRJET - Company’s Stock Price Predictor using Machine Learning
"A Framework for Developing Trading Models Based on Machine Learning" by Kris...
IRJET - Stock Market Prediction using Machine Learning Algorithm
updated stock market ppt.pptx stock market presentation

Similar to Stock market trend prediction using k nearest neighbor(knn) algorithm (20)

PDF
Stock Market Price Prediction Using Technical Analysis
PDF
Improved stock prediction accuracy using ema technique
PPTX
Stock Market Prediction using Machine Learning
PDF
Performance Comparisons among Machine Learning Algorithms based on the Stock ...
PDF
IRJET- Stock Market Prediction using Machine Learning Techniques
PPTX
Stock prediction1600759770283_ak.ppt.pptx
PDF
Predicting Stock Market Price Using Support Vector Regression
PDF
Survey Paper on Stock Prediction Using Machine Learning Algorithms
PDF
IRJET- Stock Market Prediction using ANN
PDF
Visualizing and Forecasting Stocks Using Machine Learning
PDF
STOCK PRICE PREDICTION USING MACHINE LEARNING [RANDOM FOREST REGRESSION MODEL]
PDF
STOCK MARKET PREDICTION USING MACHINE LEARNING IN PYTHON
PPTX
INFORMS 2015
PDF
Stock Price Prediction Using Sentiment Analysis and Historic Data of Stock
PDF
IRJET- Stock Market Prediction using Machine Learning
PDF
Rachit Mishra_stock prediction_report
PDF
RETRIEVING FUNDAMENTAL VALUES OF EQUITY
PDF
The International Journal of Engineering and Science (IJES)
PDF
En36855867
Stock Market Price Prediction Using Technical Analysis
Improved stock prediction accuracy using ema technique
Stock Market Prediction using Machine Learning
Performance Comparisons among Machine Learning Algorithms based on the Stock ...
IRJET- Stock Market Prediction using Machine Learning Techniques
Stock prediction1600759770283_ak.ppt.pptx
Predicting Stock Market Price Using Support Vector Regression
Survey Paper on Stock Prediction Using Machine Learning Algorithms
IRJET- Stock Market Prediction using ANN
Visualizing and Forecasting Stocks Using Machine Learning
STOCK PRICE PREDICTION USING MACHINE LEARNING [RANDOM FOREST REGRESSION MODEL]
STOCK MARKET PREDICTION USING MACHINE LEARNING IN PYTHON
INFORMS 2015
Stock Price Prediction Using Sentiment Analysis and Historic Data of Stock
IRJET- Stock Market Prediction using Machine Learning
Rachit Mishra_stock prediction_report
RETRIEVING FUNDAMENTAL VALUES OF EQUITY
The International Journal of Engineering and Science (IJES)
En36855867
Ad

More from Venkat Projects (20)

DOCX
1.AUTOMATIC DETECTION OF DIABETIC RETINOPATHY USING CNN.docx
DOCX
12.BLOCKCHAIN BASED MILK DELIVERY PLATFORM FOR STALLHOLDER DAIRY FARMERS IN K...
DOCX
10.ATTENDANCE CAPTURE SYSTEM USING FACE RECOGNITION.docx
DOCX
9.IMPLEMENTATION OF BLOCKCHAIN IN FINANCIAL SECTOR TO IMPROVE SCALABILITY.docx
DOCX
8.Geo Tracking Of Waste And Triggering Alerts And Mapping Areas With High Was...
DOCX
Image Forgery Detection Based on Fusion of Lightweight Deep Learning Models.docx
DOCX
6.A FOREST FIRE IDENTIFICATION METHOD FOR UNMANNED AERIAL VEHICLE MONITORING ...
DOCX
WATERMARKING IMAGES
DOCX
4.LOCAL DYNAMIC NEIGHBORHOOD BASED OUTLIER DETECTION APPROACH AND ITS FRAMEWO...
DOCX
Application and evaluation of a K-Medoidsbased shape clustering method for an...
DOCX
OPTIMISED STACKED ENSEMBLE TECHNIQUES IN THE PREDICTION OF CERVICAL CANCER US...
DOCX
1.AUTOMATIC DETECTION OF DIABETIC RETINOPATHY USING CNN.docx
DOCX
2022 PYTHON MAJOR PROJECTS LIST.docx
DOCX
2022 PYTHON PROJECTS LIST.docx
DOCX
2021 PYTHON PROJECTS LIST.docx
DOCX
2021 python projects list
DOCX
10.sentiment analysis of customer product reviews using machine learni
DOCX
9.data analysis for understanding the impact of covid–19 vaccinations on the ...
DOCX
6.iris recognition using machine learning technique
DOCX
5.local community detection algorithm based on minimal cluster
1.AUTOMATIC DETECTION OF DIABETIC RETINOPATHY USING CNN.docx
12.BLOCKCHAIN BASED MILK DELIVERY PLATFORM FOR STALLHOLDER DAIRY FARMERS IN K...
10.ATTENDANCE CAPTURE SYSTEM USING FACE RECOGNITION.docx
9.IMPLEMENTATION OF BLOCKCHAIN IN FINANCIAL SECTOR TO IMPROVE SCALABILITY.docx
8.Geo Tracking Of Waste And Triggering Alerts And Mapping Areas With High Was...
Image Forgery Detection Based on Fusion of Lightweight Deep Learning Models.docx
6.A FOREST FIRE IDENTIFICATION METHOD FOR UNMANNED AERIAL VEHICLE MONITORING ...
WATERMARKING IMAGES
4.LOCAL DYNAMIC NEIGHBORHOOD BASED OUTLIER DETECTION APPROACH AND ITS FRAMEWO...
Application and evaluation of a K-Medoidsbased shape clustering method for an...
OPTIMISED STACKED ENSEMBLE TECHNIQUES IN THE PREDICTION OF CERVICAL CANCER US...
1.AUTOMATIC DETECTION OF DIABETIC RETINOPATHY USING CNN.docx
2022 PYTHON MAJOR PROJECTS LIST.docx
2022 PYTHON PROJECTS LIST.docx
2021 PYTHON PROJECTS LIST.docx
2021 python projects list
10.sentiment analysis of customer product reviews using machine learni
9.data analysis for understanding the impact of covid–19 vaccinations on the ...
6.iris recognition using machine learning technique
5.local community detection algorithm based on minimal cluster
Ad

Recently uploaded (20)

PPTX
master seminar digital applications in india
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Institutional Correction lecture only . . .
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Computing-Curriculum for Schools in Ghana
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
master seminar digital applications in india
Abdominal Access Techniques with Prof. Dr. R K Mishra
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Institutional Correction lecture only . . .
GDM (1) (1).pptx small presentation for students
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Microbial disease of the cardiovascular and lymphatic systems
Computing-Curriculum for Schools in Ghana
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Microbial diseases, their pathogenesis and prophylaxis
TR - Agricultural Crops Production NC III.pdf
PPH.pptx obstetrics and gynecology in nursing
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Complications of Minimal Access Surgery at WLH
Supply Chain Operations Speaking Notes -ICLT Program
Pharma ospi slides which help in ospi learning
Renaissance Architecture: A Journey from Faith to Humanism

Stock market trend prediction using k nearest neighbor(knn) algorithm

  • 1. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com Stock Market Trend PredictionUsing K-Nearest Neighbor(KNN) Algorithm In this paper author is evaluating performance of KNN(K-Nearest Neighbor) supervised machine learning algorithm. In the finance world stocktrading is one of the most important activities. Stock market prediction is an act of trying to determine the future value of a stock other financial instrument traded on a financial exchange. The programming language is used to predict the stock market using machine learning is Python. In this paper we propose a Machine Learning (ML) approach that will be trained from the available stocks data and gain intelligence and then uses the acquired knowledge foran accurate prediction. In this context this study uses a machine learning technique called K-Nearest Neighbor to predict stockprices for the large and small capitalizations and in the three different markets, employing prices with both daily and up-to-the-minute frequencies. Predicting the Stock Market has been the bane and goal of investors since its existence. Everyday billions of dollars are traded on the exchange, and behind each dollar is an investor hoping to profit in oneway oranother. Entire companies rise and fall daily based on the behaviour of the market. Should an investor be able to accurately predict market movements, it offers a tantalizing promises of wealth and influence. It is no wonderthen that the StockMarket and its associated challenges find their way into the public imagination every time it misbehaves. The 2008 financial crisis was no different, as evidenced by the flood of films and documentaries based on the crash. If there was a common theme among those productions, it was that few people knew how the market worked or reacted. Perhaps a better understanding of stockmarket prediction might help in the case of similar events in the future. Despite its prevalence, StockMarket prediction remains a secretive and empirical art. Few people, if any, are willing to share what successfulstrategies they have. A chief goal of this project is to add to the academic understanding of stock market prediction. The hope is that with a greater understanding of how the market moves, investors will be better equipped to prevent another financial
  • 2. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com crisis. The projectwill evaluate someexisting strategies from a rigorous scientific perspective and provide a quantitative evaluation of new strategies. There are several data mining algorithms that can be used for prediction purposes in the field of finance. Some examples would be the naive Bayes classifier, the k nearest neighbour (KNN) algorithm and the classification and the regression tree algorithm (Wu et al. 2007). All the mentioned algorithms could fill the purpose ofthe paper butit will center around the kNN algorithm as a method ofpredicting stock market movements as well as the MA formula. The movements will be detected by looking at a large amount of historical data and finding patterns to establish a well estimated forecast. This specific algorithm was chosen as it is a simple but a very effective algorithm to implement when looking at large amounts of data (Berson et al. 1999).The KNN algorithm simply states: "Objects that are ’near’ to each other will have similar prediction values as well. Thus if you know the prediction value of one of the objects you can predict it for its nearest neighbours" (Berson et al. 1999). As a comparison with the KNN algorithm, the MA formula was chosen. The MA formula has its simplicity as a commonfactor with the KNN algorithm, but it is a statistical method used frequently by traders (Interactive Data Corp, 2014). There are existing techniques when it comes to stock prediction, some of them are multispectral prediction, distortion controlled prediction and lempel-ziv based prediction. These are based on the fact that the data representation is more compact by removing redundancy while the essential information is kept in format that is accessible (Azhar et al. 1994). Due to the scope of the project the techniques that were the most suitable to work with were the KNN algorithm and the MA formula despite the existing techniques listed above. To conductexperiment author has used Yahoo Finance stock Dataset and below is some example records of that dataset which contains request signatures. I have also used same dataset and this dataset is available inside ‘dataset’ folder. Dataset example ['High', 'Low', 'Open', 'Close', 'Volume', 'Adj Close'] Above list are the columns of Yahoo finance
  • 3. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com 201 7- 01- 05 116.8600 01 115.8099 98 115.9199 98 116.6100 01 22193600 .0 111.3933 03 201 7- 01- 09 119.4300 00 117.9400 02 117.9499 97 118.9899 98 33561900 .0 113.6668 24 Above two records are the APPLE stock form the Yahoo Finance Dataset. For the rest of analysis, we will use the Closing Price which remarks the final price in which the stocks are traded by the end of the day. we analyse stocks using two key measurements: Rolling Mean and Return Rate Rolling Mean: Rolling mean/Moving Average (MA) smooths out price data by creating a constantly updated average price. This is useful to cut down “noise” in our price chart. Furthermore, this Moving Average could act as “Resistance” meaning from the downtrend and uptrend of stocks you could expect it will follow the trend and less likely to deviate outside its resistance point. The Moving Average makes the line smooth and showcase the increasing or decreasing trend of stocks price.
  • 4. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com ReturnDeviation— to determineriskandreturn Expected Return measuresthe mean, or expected value, of the probability distribution of investment returns. Theexpected return of a portfolio is calculated by multiplying theweight of each asset by its expected return and addingthevalues for each investment — Investopedia. Following is the formula you could refer to:
  • 5. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com Before running code execute below two commands Screen shots
  • 6. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com Double click on ‘run.bat’ file to get below screen In above screen click on ‘Download Button’ download the Apple Stock and competitors data from Yahoo Finance Dataset
  • 7. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com In above screen I am Downloading of Apple Stock and Apple competitor Stock Data from Yahoo Finance Dataset. Now click on ‘Correlation Data’ Button to find the correlation between Apple and Competitor Stock market Dataset. show the trend in the technology industry rather than show how competing stocks affect each other. Now click on‘Data PreProcessingbutton to drop missing values, split labels split train and test
  • 8. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com After pre-processing all missing values are dropped, Separating the label here, Scalling of X, find Data Series of late X and early X (train) for model generation and evaluation, Separatelabeland identifyit as y and Separationof training and testing of model. In above screen we can see dataset contains total 1752 records and 1226 used for training and 526 used for testing. Now click on ‘Run KNN with Uniform Weights’ to generate KNN model with uniform weights and calculate its model accuracy
  • 9. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com In above screen we can see with KNN with uniform weights got 96.8% accuracy, now click on ‘Run KNN with distance weights’ to calculate accuracy
  • 10. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com In above screen we got 100% accuracy, now we will click on ‘Predict Test Data’button to upload test data and to predict whether test data stockmarket for both models. accuracy score (>0.95) for most of the models.
  • 11. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com In above screenfor each test data we got forecastvalues for Apple Stock for each test record. Now click on ‘KNN Accuracy’ button to save the predicted values for each model save in the local directory and Accuracy comparison to both the models From above graph we can see that distance weights has little bit better better accuracy compare to Uniform weights, in above graph x-axis contains algorithm name and y-axis represents accuracy of that algorithms
  • 12. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com Plotting the PredictionforKNN withUniformWeights:
  • 13. Venkat Java Projects Mobile:+91 9966499110 Visit:www.venkatjavaprojects.com Email:venkatjavaprojects@gmail.com Plotting the PredictionforKNN withDistanceWeights: