TIME-SERIES ANALYSIS: FORECASTING STOCK PRICE USING MACHINE LEARNING WITH PYTHON GUI

·
· BALIGE PUBLISHING
4.8
8 reviews
Ebook
463
Pages

About this ebook

Stock trading and financial instrument markets offer significant opportunities for wealth creation. The ability to predict stock price movements has long intrigued researchers and investors alike. While some theories, like the Efficient Market Hypothesis, suggest that consistently beating the market is nearly impossible, others contest this viewpoint.


Stock price prediction involves forecasting the future value of a given stock. In this project, we focus on the S&P 500 Index, which consists of 500 stocks from various sectors of the US economy and serves as a key indicator of US equities. To tackle this task, we utilize the Yahoo stock price history dataset, which contains 1825 rows and 7 columns including Date, High, Low, Open, Close, Volume, and Adj Close. To enhance our predictions, we incorporate technical indicators such as daily returns, Moving Average Convergence-Divergence (MACD), Relative Strength Index (RSI), Simple Moving Average (SMA), lower and upper bands, and standard deviation.


In this book, for the forecasting task, we employ various regression algorithms including Linear Regression, Random Forest Regression, Decision Tree Regression, Support Vector Regression, Naïve Bayes Regression, K-Nearest Neighbor Regression, Adaboost Regression, Gradient Boosting Regression, Extreme Gradient Boosting Regression, Light Gradient Boosting Regression, Catboost Regression, MLP Regression, Lasso Regression, and Ridge Regression. These models aim to predict the future Adj Close price of the stock based on historical data.


In addition to stock price prediction, we also delve into predicting stock daily returns using machine learning models. We utilize K-Nearest Neighbor Classifier, Random Forest Classifier, Naive Bayes Classifier, Logistic Regression Classifier, Decision Tree Classifier, Support Vector Machine Classifier, LGBM Classifier, Gradient Boosting Classifier, XGB Classifier, MLP Classifier, and Extra Trees Classifier. These models are trained to predict the direction of daily stock returns (positive or negative) based on various features and technical indicators.


To assess the performance of these machine learning models, we evaluate several important metrics. Accuracy measures the overall correctness of the predictions, while recall quantifies the ability to correctly identify positive cases (upward daily returns). Precision evaluates the precision of positive predictions, and the F1 score provides a balanced measure of precision and recall. Additionally, we consider macro average, which calculates the average metric value across all classes, and weighted average, which provides a balanced representation considering class imbalances.


To enhance the user experience and facilitate data exploration, we develop a graphical user interface (GUI). The GUI is built using PyQt and offers an interactive platform for users to visualize and interact with the data. It provides features such as plotting boundary decisions, visualizing feature distributions and importance, comparing predicted values with true values, displaying confusion matrices, learning curves, model performance, and scalability analysis. The GUI allows users to customize the analysis by selecting different models, time periods, or variables of interest, making it accessible and user-friendly for individuals without extensive programming knowledge.


The combination of exploring the dataset, forecasting stock prices, predicting daily returns, and developing a GUI creates a comprehensive framework for analyzing and understanding stock market trends. By leveraging machine learning algorithms and evaluating performance metrics, we gain valuable insights into the accuracy and effectiveness of our predictions. The GUI further enhances the accessibility and usability of the analysis, enabling users to make data-driven decisions and explore the stock market with ease.

Ratings and reviews

4.8
8 reviews
Sajan Sidhu
March 1, 2024
Sl vs Vcd Aww
Did you find this helpful?

About the author

Vivian Siahaan is a fast-learner who likes to do new things. She was born, raised in Hinalang Bagasan, Balige, on the banks of Lake Toba, and completed high school education from SMAN 1 Balige. She started herself learning Java, Android, JavaScript, CSS, C ++, Python, R, Visual Basic, Visual C #, MATLAB, Mathematica, PHP, JSP, MySQL, SQL Server, Oracle, Access, and other programming languages. She studied programming from scratch, starting with the most basic syntax and logic, by building several simple and applicable GUI applications. Animation and games are fields of programming that are interests that she always wants to develop. Besides studying mathematical logic and programming, the author also has the pleasure of reading novels. Vivian Siahaan has written dozens of ebooks that have been published on Sparta Publisher: Data Structure with Java; Java Programming: Cookbook; C ++ Programming: Cookbook; C Programming For High Schools / Vocational Schools and Students; Java Programming for SMA / SMK; Java Tutorial: GUI, Graphics and Animation; Visual Basic Programming: From A to Z; Java Programming for Animation and Games; C # Programming for SMA / SMK and Students; MATLAB For Students and Researchers; Graphics in JavaScript: Quick Learning Series; JavaScript Image Processing Methods: From A to Z; Java GUI Case Study: AWT & Swing; Basic CSS and JavaScript; PHP / MySQL Programming: Cookbook; Visual Basic: Cookbook; C ++ Programming for High Schools / Vocational Schools and Students; Concepts and Practices of C ++; PHP / MySQL For Students; C # Programming: From A to Z; Visual Basic for SMA / SMK and Students; C # .NET and SQL Server for High School / Vocational School and Students. At the ANDI Yogyakarta publisher, Vivian Siahaan also wrote a number of books including: Python Programming Theory and Practice; Python GUI Programming; Python GUI and Database; Build From Zero School Database Management System In Python / MySQL; Database Management System in Python / MySQL; Python / MySQL For Management Systems of Criminal Track Record Database; Java / MySQL For Management Systems of Criminal Track Records Database; Database and Cryptography Using Java / MySQL; Build From Zero School Database Management System With Java / MySQL.

Rismon Hasiholan Sianipar was born in Pematang Siantar, in 1994. After graduating from SMAN 3 Pematang Siantar 3, the writer traveled to the city of Jogjakarta. In 1998 and 2001 the author completed his Bachelor of Engineering (S.T) and Master of Engineering (M.T) education in the Electrical Engineering of Gadjah Mada University, under the guidance of Prof. Dr. Adhi Soesanto and Prof. Dr. Thomas Sri Widodo, focusing on research on non-stationary signals by analyzing their energy using time-frequency maps. Because of its non-stationary nature, the distribution of signal energy becomes very dynamic on a time-frequency map. By mapping the distribution of energy in the time-frequency field using discrete wavelet transformations, one can design non-linear filters so that they can analyze the pattern of the data contained in it. In 2003, the author received a Monbukagakusho scholarship from the Japanese Government. In 2005 and 2008, he completed his Master of Engineering (M.Eng) and Doctor of Engineering (Dr.Eng) education at Yamaguchi University, under the guidance of Prof. Dr. Hidetoshi Miike. Both the master's thesis and his doctoral thesis, R.H. Sianipar combines SR-FHN (Stochastic Resonance Fitzhugh-Nagumo) filter strength with cryptosystem ECC (elliptic curve cryptography) 4096-bit both to suppress noise in digital images and digital video and maintain its authenticity. The results of this study have been documented in international scientific journals and officially patented in Japan. One of the patents was published in Japan with a registration number 2008-009549. He is active in collaborating with several universities and research institutions in Japan, particularly in the fields of cryptography, cryptanalysis and audio / image / video digital forensics. R.H. Sianipar also has experience in conducting code-breaking methods (cryptanalysis) on a number of intelligence data that are the object of research studies in Japan. R.H. Sianipar has a number of Japanese patents, and has written a number of national / international scientific articles, and dozens of national books. R.H. Sianipar has also participated in a number of workshops related to cryptography, cryptanalysis, digital watermarking, and digital forensics. In a number of workshops, R.H. Sianipar helps Prof. Hidetoshi Miike to create applications related to digital image / video processing, steganography, cryptography, watermarking, non-linear screening, intelligent descriptor-based computer vision, and others, which are used as training materials. Field of interest in the study of R.H. Sianipar is multimedia security, signal processing / digital image / video, cryptography, digital communication, digital forensics, and data compression / coding. Until now, R.H. Sianipar continues to develop applications related to analysis of signal, image, and digital video, both for research purposes and for commercial purposes based on the Python programming language, MATLAB, C ++, C, VB.NET, C # .NET, R, and Java.

Rate this ebook

Tell us what you think.

Reading information

Smartphones and tablets
Install the Google Play Books app for Android and iPad/iPhone. It syncs automatically with your account and allows you to read online or offline wherever you are.
Laptops and computers
You can listen to audiobooks purchased on Google Play using your computer's web browser.
eReaders and other devices
To read on e-ink devices like Kobo eReaders, you'll need to download a file and transfer it to your device. Follow the detailed Help Center instructions to transfer the files to supported eReaders.