(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
Stock Market Prediction Using ANN
1. REPORT
STOCK MARKET PREDICTION USING ANN
Submitted By-
Krishna Mohan Mishra
Roll No-B47
Reg. No-11605503
Section-KEM62
[1]
2. INTRODUCTION
Stock market prediction is the act of trying to determine the future value of a company
stock or other financial instrument traded on an exchange. The successful prediction of a
stock's future price could yield significant profit. The efficient market hypothesis suggests
that stock prices reflect all currently available information and any price changes that are
not based on newly revealed information thus are inherently unpredictable.
Prediction of stock market returns is an important issue in finance. Nowadays artificial
neural networks (ANNs) have been popularly applied to finance problems such as stock
exchange index prediction, bankruptcy prediction and corporate bond classification.
ANN model is a computer model whose architecture essentially mimics the learning
capability of the human brain. The processing elements of an ANN resemble the biological
structure of neurons and the internal operation of a human brain. Many simple
interconnected linear or nonlinear computational elements are operating in parallel
processing at multiple layers. In some applications it has been specified that ANNs have
limitations for learning the data patterns. They may perform inconsistently and
unpredictable because of the complex financial data used. Sometimes data is so voluminous
that learning patterns may not work. Continuous and large volume of data needs to be
checked for redundancy and the data size should be decreased for the algorithm to work in
a shorter time and give more generalized solutions.
SUPPORT VECTOR MACHINE
In machine learning support vector machines are supervised learning models with
associated learning algorithms that analyze data used for classification and regression
analysis. Given a set of training examples, each marked as belonging to one or the other of
two categories, an SVM training algorithm builds a model that assigns new examples to one
category or the other, making it a non-probabilistic binary linear classfier.
An SVM model is a representation of the examples as points in space, mapped so that the
examples of the separate categories are divided by a clear gap that is as wide as possible.
In addition to performing linear classification, SVMs can efficiently perform a non-linear
classification using what is called the kernel trick, implicitly mapping their inputs into high-
dimensional feature spaces.
When data is unlabelled, supervised learning is not possible, and an unsupervised learning
approach is required, which attempts to find natural clustering of the data to groups, and
then map new data to these formed groups. The support vector clustering algorithm,
created by Hava Siegelman and Vladimir Vapnik, applies the statistics of support vectors,
developed in the support vector machines algorithm, to categorize unlabeled data, and is
one of the most widely used clustering algorithms in industrial applications.
Support Vector Regression-
A version of SVM for regression was proposed in 1996 by Vladimir Vapnik, Harris Drucker,
Christopher J. C. Burges, Linda Kaufman and Alexander J. Smola. This method is called
support vector regression (SVR). The model produced by support vector classification
depends only on a subset of the training data, because the cost function for building the
model does not care about training points that lie beyond the margin. Analogously, the
model produced by SVR depends only on a subset of the training data, because the cost
function for building the model ignores any training data close to the model prediction.
In sci-kit learn SVM regression models are implemented using the svm.SVR class.
5. DATA SETS
LIBRARIES IMPORTED
● from sklearn.svm import SVR – support vector regressor
● import csv-- The so-called CSV (Comma Separated Values) format
is the most common import and export format for spreadsheets and
Fig.1 Code Screenshots
Fig.2 Data Sets Screenshot
[4]
6. databases.The csv module implements classes to read and write
tabular data in CSV format.
● import numpy as np-- is a library for the Python programming
language, adding support for large, multi-dimensional arrays and
matrices, along with a large collection of high-level
mathematical functions to operate on these arrays.
● import matplotlib.pyplot as plt-- matplotlib is a plotting
library for the Python programming language and its numerical
mathematics extension NumPy. It provides an object-oriented API
for embedding plots into applications using general-purpose GUI
Toolkit.
kernel- These are functions which takes low dimensional input space
and transform it to a higher dimensional space i.e. it converts not
separable problem to separable problem, these functions are called
kernels. It is mostly useful in non-linear separation problem.
Here, we have various options available with kernel like, “linear”,
“rbf”,”poly” and others (default value is “rbf”). Here “rbf” and
“poly” are useful for non-linear hyper-plane.
gamma: Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’. Higher the
value of gamma, will try to exact fit the as per training data set
i.e. generalization error and cause over-fitting problem.
Example: Let’s difference if we have gamma different gamma values
like 0, 10 or 100.
Example : use of kernel in code-
svr_rbf = SVR(kernel= 'rbf', C= 1e3, gamma= 0.1)
svr_lin = SVR(kernel= 'linear', C= 1e3)
Fig.3 Difference between different gamma values
7. svr_poly = SVR(kernel= 'poly', C= 1e3, degree= 2)
Methods:
➢ fit- Fit the SVM model according to the given training data.
svr_rbf.fit(dates, prices)
svr_lin.fit(dates, prices)
svr_poly.fit(dates, prices)
➢ predict-Perform regression on samples in X.
svr_rbf.predict(x)[0], svr_lin.predict(x)[0], svr_poly.predict(x)[0]
➢ Scatter- built-in function to create scatter plots
plt.scatter(dates, prices, color= 'black', label= 'Data')
[5]