Stock Market Prediction Using Feed-forward Artificial Neural Network

1y ago
6 Views
1 Downloads
797.36 KB
5 Pages
Last View : 10d ago
Last Download : 3m ago
Upload by : Amalia Wilborn
Transcription

International Journal of Computer Applications (0975 – 8887)Volume 99– No.9, August 2014Stock Market Prediction using Feed-forward ArtificialNeural NetworkSuraiya JabinDepartment of Computer Science,Jamia Millia Islamia, New DelhiABSTRACTThis paper presents computational approach for stock marketprediction. Artificial Neural Network (ANN) forms a usefultool in predicting price movement of a particular stock. In theshort term, the pricing relationship between the elements of asector holds firmly. An ANN can learn this pricingrelationship to high degree of accuracy and be deployed togenerate profits with sufficiently large amounts of data,preferably in times of low volatility and over a short timeperiod. Experimental results are presented to demonstrate theperformance of the proposed system. The paper also aims tosuggest about training algorithms and training parameters thatmust be chosen in order to fit time series kind of complicateddata to a neural network model. The proposed modelsucceeded in prediction of the trends of stock market with100% prediction accuracy.General TermsPattern Recognition, Stock Market PredictionKeywordsBPNN, DAX, nntool, newff, trainbr, trainscg, trainrp1. INTRODUCTIONPrediction of stock market returns has been one of the mostchallenging problem to the AI community. For solving thisproblem, diverse kind of technical, fundamental, andstatistical indicators have been proposed and used for exampleRegression, Support Vector Machines (SVM) with contrastingresults. However, none of these techniques or combination oftechniques had been successful enough. The objective ofprediction research has been largely beyond the capability oftraditional AI research which has mainly focused ondeveloping intelligent systems that are supposed to emulatehuman intelligence. By its nature the stock market is mostlycomplex (non-linear) and volatile. With the development ofartificial neural networks investors are benefitting byunleashing the market mysteries. These days’ artificial neuralnetworks are considered as a common data mining method indifferent fields like economy, business, industry, weatherforecasting and science. Artificial neural networks have beensuccessfully used in stock market prediction during the lastdecade. The benchmark performance of neural networkmodels in exchange rate forecasting has been established in anumber of recent papers [1].Neural network learning methods provide a robust approachto approximating real-valued, discrete valued, and vectorvalued target functions. The application of artificial neuralnetworks in prediction problems is very promising due tosome of their special characteristics.First, artificial neural networks can find the relationshipbetween the input and output of the system even if thisrelationship might be very complicated because they aregeneral function approximations. Consequently, artificialneural networks are well applied to the problems in whichextracting the relationships among data is really difficult buton the other hand there exists a large enough training datasets.Second, artificial neural networks have generalization abilitymeaning that after training they can recognize the newpatterns even if they haven’t been in training set. Since inmost of the pattern recognition problems predicting futureevents (unseen data) is based on previous data (training set),the application of artificial neural networks would be verybeneficial.Third, artificial neural networks have been claimed to beexcellent general function approximates. It is proved that aMulti-layer perceptrons (MLP) can approximate any complexcontinuous function that enables us to learn any complicatedrelationship between the input and the output of the system.Artificial neural networks are mostly used in predictingfinancial failures. This paper presents use of artificial neuralnetworks to predict State Bank of India (SBI) Magnum TaxGain scheme (Regular plan with growth option) Net AssetValue (NAV) value. The two year data set has beendownloaded from bank’s website (www.sbimf.com). Multipleexperiments were performed by taking different topologies ofthe feed forward network along with different trainingparameters like training function and transfer/output function.Experimental results are presented to demonstrate theperformance of the error back propagation method for stockprediction.2. REVIEW OF LITERATUREAll ANNs are being used in various fields of applicationincluding business forecasting, credit scoring, bond rating,business failure prediction, medicine, pattern recognition,image processing, speech processing, computer vision andcontrol systems. In the context of financial forecasting, Kuanand Liu [2] show that a properly designed ANN has lowerout-of-sample mean squared prediction error relative to therandom walk model. Jasic and Wood [3] discuss theprofitability of trading signals generated from the out-ofsample short-term predictions for daily returns of S&P 500,DAX, TOPIX and FTSE stock market indices evaluated overthe period 1965–99. The out-of sample predictionperformance of neural networks is compared against abenchmark linear autoregressive model. They found that thebuy and sell signals derived from neural network predictionsare significantly different from unconditional one-day meanreturn and are likely to provide significant net profits forreasonable decision rules and transaction cost assumptions.They report that ANNs outperform the linear models fromfinancial forecasting literature in terms of its predictivepower. It is reported that the neural network models yieldstatistically lower forecast errors for the year-over year4

International Journal of Computer Applications (0975 – 8887)Volume 99– No.9, August 2014growth rate of real GDP relative to linear and univariatemodels. Huang et al. [4] report a comparative study ofapplication of Support Vector Machines (SVM) andBackpropagation Neural Networks (BPNN) for an analysis ofcorporate credit ratings. They report that the performances ofSVM and BNN in this problem were comparable and boththese models achieved about 80 per cent prediction accuracy.It is reported that ANNs perform better than the statisticaldiscriminant analysis both for training and hold-out samples.All the recent literatures [5, 6] have also echoed the sameabout neural networks.3. BACK PROPAGATION METHODNeural networks have been touted as all-powerful tools instock-market prediction. Various companies claim amazing199.2% returns over a 2-year period using their neuralnetwork prediction methods. Backpropagation neural network(BPNN) algorithm uses gradient descent to tune networkparameters to best fit a training set of input-output pairs.BPNN has proven surprisingly successful in many practicalproblems such as learning to recognize hand writtencharacters, to recognize spoken words and learning torecognize faces [7]. Backpropagation method combines HillClimbing and Gradient Descent. It does Hill Climbing byGradient Descent. Hill Climbing tries each possible step tochoose a step that does the most good at every step. GradientDescent tries moving in the direction of most rapidperformance improvement. Gradient Descent requires asmooth threshold function and not the stair step thresholdfunction which outputs 0 or 1 as stair step threshold functionis discontinuous and is un-differentiable and hence unsuitablefor gradient descent. One solution is the sigmoid unit, whichis very much like a perceptron but based on a smoothed,differentiable threshold function. Athough in practice tansig(tan hyperbolic) function is preferred for faster learning. 1.where D is the set of training examples, td is the target outputfor training example d, and od is the output of the linear unitfor training example d. By this definition, E ( ) is simply halfthe squared difference between the target output td and thehearunit output od, summed over all training examples. Here wecharacterize E as a function of ( ), because the linear unitoutput o depends on this weight vector along with on aparticular set of training examples.To understand the gradient descent algorithm it is helpful tovisualize the entire hypothesis space of possible weightvectors and their associated error (E ( )) values, as illustratedin figure 2. This error surface is parabolic with a single globalminimum for a single unit with just two inputs.Fig 2: Error of different weight vectors for a linear unitwith two weightsGradient descent search determines a weight vector thatminimizes error E by starting with an arbitrary initial weightvector, then repeatedly modifying it in small steps. At eachstep, the weight vector is altered in the direction that producesthe steepest descent along the error surface depicted in Figure2. This process continues until the global minimum error isreached.3.2 Backpropagation algorithm. .Fig 1: The Sigmoid Threshold Unit3.1 Delta Training RuleThe delta training rule is best understood by considering thetask of training an unthresholded perceptron; that is, a linearunit for which the output O is given by:Thus, a linear unit corresponds to the first stage of aperceptron, without the threshold. In order to derive a weightlearning rule for linear units, let us begin by specifying ameasure for the training error of a hypothesis (weight vector),relative to the training examples. Although there are manyways to define this error, one common measure that will turnout to be especially convenient is:This algorithm learns the weights for a fully connected feedforward multilayer network. s. It employs gradient descent toattempt to minimize the squared error between the networkoutput values and the target values for these outputs.Backpropagation (training eaxamples, rate of learning ɳ, unitsin input layer nin, units in output layer nout, units in hiddenlayer nhidden) [7]: Each training example is a pair of the form(, where is the vector of network input values, and isthe vector of target network output values. The input fromunit i into unit j is denoted xji, and the weight from unit i tounit j is denoted wji.a. Create a feed-forward network with nin, inputs, nhiddenhidden units, and nout output units.b. Initialize all network weights to small random numbers(e.g., between -0.05 and 0.05).c. Until the termination condition is met, Do For eachtraining eaxamples, do:in-Propagate the input forward through the network:5

International Journal of Computer Applications (0975 – 8887)Volume 99– No.9, August 2014 Input the instance to the network and compute theoutput of every unit in the network.-Propagate the errors backward through the network: For each network output unit k, calculate its errortermFor each hidden unit h, calculate its error term Update each network weightOne major difference in the case of multilayer networks is thatthe error surface can have multiple local minima, in contrastto the single minimum parabolic error surface shown in figure2. Gradient descent is guaranteed only to converge towardsome local minima, and not necessarily the global minimumerror.3.3 Convergence and local minimaDespite the lack of assured convergence to the globalminimum error, BPNN is a highly effective functionapproximation method in practice. In many practicalapplications the problem of local minima has not been foundto be as severe as one might fear. To develop some intuitionhere, consider that networks with large numbers of weightscorrespond to error surfaces in very high dimensional spaces(one dimension per weight). When gradient descent falls intoa local minimum with respect to one of these weights, it willnot necessarily be in a local minimum with respect to theother weights. In fact, the more weights in the network, themore dimensions that might provide escape routes forgradient descent to fall away from the local minimum withrespect to this single weight [7].3.3.1 Accelerations to Backpropagation methodA multilayer network, in general, learns much faster when thesigmoidal activation function is represented by a hyperbolictangent (tanh). Also we can train multiple networks using thesame data, but initializing each network with different randomweights.3.3.1.1 Use of momentumBy making weight update on the nth iteration dependent onupdate during the (n-1) th iteration: w ji (n) j x ji w ji (n 1)here, 0 1, is a consant called momentum.traingdm is a network training function in MATLAB thatupdates weight and bias values according to gradient descentwith momentum.3.3.1.3 Adaptive learning rateIf rate of learning is too large, the gradient descent search runsthe risk of overstepping the minimum in the error surfacerather than settling into it. To avoid it, common modificationto the algorithm is to gradually reduce the value of learningrate as the no. of gradient descent steps grows. traingda is anetwork training function that updates weight and bias valuesaccording to gradient descent with adaptive learning rate.traingdx is a network training function in MATLAB thatupdates weight and bias values according to gradient descentmomentum and an adaptive learning rate.4. STOCK MARKET PREDICTIONUSING ANN4.1 Data preprocessingA mutual fund (MF) is a financial product that pools moneyof different individuals and invest on their behalf into variousassets such as equity, debt or gold. Based on one’s financialgoal or risk appetite, there are several MF schemes to choosefrom. Few startling features that they offer are simplicity,affordability, professional management, diversification alongwith liquidity. The proposed work does prediction of NetAsset Value (NAV) of SBI mutual fund by training feedforward neural network. In stocks and businesses, NAV is anexpression of the underlying value of the company; i.e. it is astatement of the value of the company's assets minus the valueof its liabilities. One way of thinking about the net asset valueis that it is the underlying value of a company, not the valuedictated by the supply and demand of shares or its marketcapitalization. For the proposed work, the SBI magnum taxgain NAV values were taken for the duration of April 1, 2012to April 4, 2014. Data is organized with regard to workingdays in Indian Stock Exchange.As a strategy, the sequences of 4 days’ index values weretaken as input to predict each 5th day index value. In thetraining set 5th day’s NAV is the supervised value. The goal isto find such a weight matrix that minimizes the error at theoutput layer using backpropagation method.Next, the network topology is defined: what type of network,how many layers and how many neurons per layer are used.Actually, there is no rule for this, and usually it is determinedexperimentally. However the common type of network usedfor prediction is a multi layer perceptron.A recommendation is to have 2n 1 nodes for hidden-layer,where n is the number of the input nodes. The output layer hasonly one node in this case. The good results were obtainedwith the following topology and parameter set:maxIteration 10000, learningRate 0.7, maxerror 0.0001 alsosummarized in table 1 and table 2.3.3.1.2 Use Incremental/ Stochastic gradientdescentStochastic gradient descent algorithm updates weightsincrementally, upon examining each individual trainingexample rather than computing weight updates after summingover the entire training example as was done in true gradientdescent method. Here we have lesser computations. It cansometimes avoid falling into local minima as it uses thevarious gradients rather than just one gradient to guide itssearch.6

International Journal of Computer Applications (0975 – 8887)Volume 99– No.9, August 2014optimization. It minimizes a combination of squared errorsand weights, and then determines the correct combination soas to produce a network that generalizes well. The process iscalled Bayesian regularization.NAV atDay 1NAV atDay 14.2.1.3 trainscgHiddenunit 1NAV atDay 5NAV atDay 1Hiddenunit 2NAV atDay 1Input layerHidden layerOutput layerFig 3: A simplified three-layer feed forward networkto solve stock prediction on Day 5 when given inputwith previous four days values4.2 ExperimentsMultiple experiments were performed by taking differenttopologies of the feed forward network along with differenttraining parameters like training function and transfer/outputfunction as summarized in table 1.Table 1. Parameters for creating anceFunctionMSE(MeanSquaredError)SSE (SumSquaredError)SSE(MeanSquaredError)trainscg is a network training function that updates weightand bias values according to the scaled conjugate gradientmethod.4.3 Results and DiscussionThe process of training a neural network involves tuning thevalues of weights and biases of the network to optimizenetwork performance function. The default performancefunction for feed-forward network is mean square error (mse)i.e. the average squared error between the network outputsand the target outputs. Experimental results are presented todemonstrate the performance of the backpropagation methodfor stock prediction.Training occurs according to followingtraining parameters, shown in table 2 with their experimentaland default values.Table 2. The chosen training t.trainParam.max fail6004-2020-201Tansig/logsignet.trainParam.min 0014-2020-201Tansig/logsignet.trainParam.mu decnet.trainParam.mu incnet.trainParam.mu am.time0Topology4.2.1 Training functionsThe default training function is trainlm but it could not dowell for stock prediction. When training large networks andspecially training for pattern recognition, trainbr, trainscg andtrainrp are good choices. For training the feed forwardnetwork, different training functions were tried with differenttopologies of the network (e.g. 4-20-20-20-1, 4-20-20-1, 4-1515-1, 4-20-1, 4-40-1) and after exhaustive experiments withvarying training functions, it was found that with followingthree training functions, good results can be obtained forlearning time-series kind of data.4.2.1.1 trainrptrainrp is a network training function that updates weight andbias values according to the resilient backpropagationalgorithm (Rprop).4.2.1.2 trainbrtrainbr is a network training function that updates the weightand bias values according to Levenberg-Marquardt1InfDescription withdefault valueMaximum numberof epochs to train;default value 1000Performance goal(to minimize error)Maximumvalidation failures;default value 6MinimumperformancegradientInitial mu (thelearning rate)mu decrease factormu increase factorMaximum muEpochs betweendisplays (NaN forno displays)Generate commandline outputShow training GUIMaximum time totrain in secondsTraining stops when any of these conditions occurs [8]: The maximum number of epochs (repetitions) isreached.The maximum amount of time is exceeded.Performance is minimized to the goal.The performance gradient falls below min grad.mu exceeds mu max.Validation performance has increased more thanmax fail times since the last time it decreased(when using validation).7

International Journal of Computer Applications (0975 – 8887)Volume 99– No.9, August 2014The experimental results are summarized in table 3. It isfound that the results were not satisfactory for networks withjust one hidden layer. The training function trainbr performedwell for 2 or 3 hidden layers.Table 3. Results of two most successful experiments withFeed-forward backpropagation network with best resultsfrom training function 0.13104 at11120-20-1epoch 6914-20trainbr0.22893 at10.890.9520-1epoch 3061Experiments suggested that trainbr is the most suitabletraining method for stock market prediction.5. ANALYSIS OF NETWORK AFTERTRAININGThe figure 4 shows the plot of validation performance versuseach iteration for proposed feed-forward network model withtopology 4-20-20-20-1 and trainbr as the training functionchosen. Training stops when the performance on the nontraining validation set fails to decrease.The next step in validating the network is to create aregression plot, which shows the relationship between theoutputs of the network and the targets. If the training wereperfect, the network outputs and the targets would be exactlyequal, but the relationship is rarely perfect in practice.variations in no. of hidden layers, no. of neurons in hiddenlayers, and different training parameters. Larger numbers ofneurons in the hidden layer give the network more flexibilitybecause the network has more parameters it can optimize butat the same time it increases time and space complexity.Experiments were done by increasing the layer size gradually.If hidden layer size is made too large, it may cause theproblem to be under-characterized and it may result in thenetwork optimizing more parameters than there are datavectors to constrain these parameters. While experimentingwith different training functions it was found that Bayesianregularization training with trainbr produces bettergeneralization capability than using early stopping. Thefollowing conclusion can be drawn about ANNs; it has abilityto extract useful information from large set of data thereforeANNs play very important role in stock market prediction.7. ACKNOWLEDGMENTSMy special thanks to the students (Deepak Bisht and RajeshMaulekhi) who contributed towards preprocessing of the dataset.8. REFERENCES[1] Teo Jasic, Douglas Wood: Neural network protocols andmodel performance. Neurocomputing 55(3-4): 747-753(2003)[2] Chung-Ming Kuan and Tung Liu. December (1995).Forecasting Exchange Rates Using Feedforward andRecurrent Neural Networks. Journal of Applied ofEconometrics 10 (4): 347-364.[3] Mn Y. LeCun, L. D. Jackel, B. Boser, J. S. Denker, H. P.Graf, I. Guyon, D. Henderson, R. E. Howard and W.Hubbard: Handwritten Digit Recognition: Applicationsof Neural Net Chips and Automatic Learning, IEEECommunication, 41-46, invited paper, November 1989.[4] Min, J. H., & Lee, Y. C. (2005). Bankruptcy predictionusing support vector machine with optimal choice ofkernel function parameters. Expert systems withapplications, 28(4), 603-614.[5] Najeb Masoud, Predicting Direction of Stock PricesIndex Movement Using Artificial Neural Networks:TheCase of Libyan Financial Market, British Journal ofEconomics, Management & Trade, 4(4): 597-619, 2014.[6] Akbilgic, O., Bozdogan, H., Balaban, M.E., (2013) Anovel Hybrid RBF Neural Networks model as 22-013-9375-7Fig 4: Performance plot of feed-forward network withtopology 4-20-20-20-1 and training function trainbr[7] Mitchell, Tom M. "Machine learning. 1997." Burr Ridge,IL: McGraw Hill 45 (1997).6. CONCLUSIONSThis paper investigates stock market prediction using feedforward neural network. Experiments were done by doingIJCATM : www.ijcaonline.org8

stock-market prediction. Various companies claim amazing 199.2% returns over a 2-year period using their neural network prediction methods. Backpropagation neural network (BPNN) algorithm uses gradient descent to tune network parameters to best fit a training set of input-output pairs.

Related Documents:

An ecient stock market prediction model using hybrid feature reduction method based on variational autoencoders and recursive feature elimination Hakan Gunduz* Introduction Financial prediction, especially stock market prediction, has been one of the most attrac - tive topics for researchers and investors over the last decade. Stock market .

This research tries to see the influence of G7 and ASEAN-4 stock market on Indonesian stock market by using LASSO model. Stock market estimation method had been conducted such as Stock Market Forecasting Using LASSO Linear Regression Model (Roy et al., 2015) and Mali et al., (2017) on Open Price Prediction of Stock Market Using Regression Analysis.

The stock market is dynamic, non-stationary and complex in nature, the prediction of stock price index is a challenging task due to its chaotic and non linear nature. The prediction is a statement about the future and based on this prediction, investors can decide to invest or not to invest in the stock market [2]. Stock market may be

1. BASIC INTRODUCTION OF STOCK MARKET A stock market is a public market for trading of company stocks. Stock market prediction is the task to find the future price of a company stock. The price of a share depends on the number of people who want to buy or sell it. If there are more buyers, then prices will rise. If the seller has a number of .

efficient and has a strong potential for short-term share market prediction. Keywords: Stock market, prediction using, time series analysis 1. Introduction The stock market is a general term which refers to the collection of markets where the issuing and trading of equities, bonds and other sorts of securities takes place through various physical

Stock market prediction is the act of trying to determine the future value of a company stock or other financial instrument traded on a financial exchange. The successful prediction of a stock's future price could yield significant profit. The stock market is not an efficient market.

measures used to proxy for stock market size and the size of real economy. Most of the existing studies use stock market index as a proxy for measuring the growth and development of stock market in a country. We argue that stock market index may not be a good measure of stock market size when looking at its association with economic growth.

Poultry & Cattle Feed Animal Feed and Food Industry, Poultry Feed, Fodder, Feed Manufacturing Unit, Feed for Domesticated Livestock, Indian Poultry & Cattle Feed Industry Manufacturing Plant, Detailed Project Report, Profile, Business Plan, Industry Trends, Market Research, Survey, Manufacturing Process,