0% found this document useful (0 votes)
25 views

AI Project 2 Report

The document discusses using a neural network to predict stock prices based on historical data from Kaggle. It chose the Long Short-Term Memory (LSTM) model due to its ability to capture patterns in sequential time series data. The model was trained on past stock opening and closing prices to predict future values of these attributes. Evaluation metrics like test loss, mean absolute error, mean squared error and R^2 score indicated the neural network achieved reasonably accurate results in forecasting stock prices.

Uploaded by

y.tarek
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

AI Project 2 Report

The document discusses using a neural network to predict stock prices based on historical data from Kaggle. It chose the Long Short-Term Memory (LSTM) model due to its ability to capture patterns in sequential time series data. The model was trained on past stock opening and closing prices to predict future values of these attributes. Evaluation metrics like test loss, mean absolute error, mean squared error and R^2 score indicated the neural network achieved reasonably accurate results in forecasting stock prices.

Uploaded by

y.tarek
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CSEN 933 Artificial Intelligence

Project 2: Neural Network

Report

Youssef Tarek 52-2035


Haidy Khamis 52-3101
Tasneem Ali 52-7046
Salma El-Sheikh 52-1138

BI T-9
1. Discussion of the problem, the challenges why this problem is important, and the
methodology used in assessing such a problem.

Time series forecasting is a challenging problem that involves predicting future values based on
past observations. When applied to stock prices, this task becomes particularly complex due to
the myriad of factors influencing financial markets. Investors, traders, and financial institutions
are keenly interested in accurate predictions as they can significantly impact investment
decisions, risk management, and overall financial performance.

Challenges:
1. Non-linearity and Volatility:
Stock prices exhibit non-linear patterns, and financial markets are highly volatile. This makes
predicting future prices challenging, as traditional linear models may not capture the intricate
relationships and sudden market movements.
2. Randomness and Uncertainty:
Financial markets are influenced by a multitude of unpredictable factors such as geopolitical
events, economic indicators, and investor sentiment. Incorporating these dynamic variables into a
forecasting model adds an element of randomness and uncertainty.
3. Data Quality and Noise:
Financial time series data can be noisy and contain outliers. Additionally, the quality and
availability of historical data may vary, posing challenges in building robust and accurate
forecasting models.
4. Interconnected Variables:
Stock prices are influenced by a complex web of interconnected variables, including interest
rates, company performance, market trends, and global economic conditions. Capturing these
interdependencies is essential for accurate forecasting.
5. Short-term vs. Long-term Dynamics:
Stock prices are subject to both short-term fluctuations and long-term trends. Striking a balance
between capturing immediate market reactions and understanding broader economic shifts is
crucial for effective forecasting.
Importance of the Problem:
1. Investment Decision-Making:
Accurate stock price forecasts aid investors in making informed decisions, optimizing portfolios,
and managing risks. Poor predictions can lead to financial losses and negatively impact
investment strategies.
2. Financial Market Stability:
Stock prices are indicative of overall market health. Reliable forecasts contribute to the stability
and confidence of financial markets, preventing panic selling or irrational market behavior.
3. Risk Management:
Financial institutions rely on accurate forecasts to manage risk effectively. Understanding
potential price movements helps in developing risk mitigation strategies and complying with
regulatory requirements.

Methodology:
1. Statistical Models:
Time series forecasting often begins with statistical models such as autoregressive integrated
moving averages (ARIMA) or seasonal decomposition of time series (STL). These models
capture underlying trends and seasonality.
2. Machine Learning Algorithms:
Advanced machine learning techniques, including but not limited to recurrent neural networks
(RNNs), long short-term memory networks (LSTMs), and gradient boosting machines (GBMs),
are increasingly popular for capturing complex patterns in stock price data.
3. Feature Engineering:
Identification and inclusion of relevant features such as trading volumes, technical indicators,
and external economic factors enhance the predictive power of models.
4. Ensemble Methods:
Combining predictions from multiple models or algorithms through ensemble methods like
bagging or stacking can improve overall forecasting accuracy.
5. Deep Learning and Neural Networks:
Deep learning models, particularly neural networks, have shown promise in capturing intricate
patterns and dependencies in time series data. These models can adapt to the non-linear nature of
stock prices.
6. Evaluation Metrics:
Commonly used metrics for assessing the performance of time series forecasting models include
mean absolute error (MAE), mean squared error (MSE), root mean squared error (RMSE), and
accuracy metrics tailored to financial forecasting like the Sharpe ratio.

2. Discussion about the reasoning behind the choices made for the dataset of Kaggle
1. Relevance to the Problem:
The dataset from Kaggle is specifically designed for time series forecasting with Yahoo Stock
Price, aligning perfectly with the problem at hand. This ensures that the data is directly
applicable to the task of predicting stock prices, providing a realistic and practical foundation for
the case study. It’s also considered a business problem and that’s exactly what we want to focus
on.
2. Data Quality and Completeness:
Kaggle datasets often go through a vetting process, ensuring a certain level of data quality and
completeness. The Yahoo Stock Price dataset is likely to be well-structured, containing historical
stock price data with minimal missing values or inconsistencies. This is crucial for building
reliable forecasting models.
3. Historical Data Range:
The dataset's period is a crucial consideration. A dataset covering a sufficiently long historical
period allows the model to capture a wide range of market conditions, including various
economic cycles and potential financial crises. This aids in building more robust and adaptive
forecasting models.
4. Incorporation of Relevant Features:
The dataset is expected to include just the right amount of relevant features for the prediction and
the modeling. Having a diverse set of features enriches the dataset and provides more
information for the forecasting models.
3. Discussion about the importance of the attributes which are chosen as the attributes
upon which the predictive model is based, alongside the attributes to be predicted.

In our dataset, we started with important columns like "high" and "low" indicating the stock's
price range, and "open" and "close" showing the starting and ending prices in a given period.
We noticed a redundant column, "adjusted close," with values identical to "close." We dropped
the "adjusted close" column to keep things clear, eliminating redundancy.
Although "volume" gauges overall trading activity, we chose to exclude it from our predictive
model. This decision aimed to streamline and optimize the model by focusing solely on essential
stock price factors.
For our predictive modeling, we turned to Long Short-Term Memory (LSTM), a robust neural
network designed for capturing patterns in sequential data. This choice was ideal for our goal of
forecasting stock prices over time.
Our main aim was to use LSTM to predict opening and closing prices. By training the model on
historical "open" and "close" values, we aimed to tap into its ability to identify patterns and
trends, ultimately generating accurate predictions for these crucial stock parameters.

4. In case of a variation of the Neural Network is utilized (CRR, RNN, or LSTM for
example), an introduction to the variation used should be provided, alongside an
argument about the suitability of the variation to the problem nature.

For our task of predicting stock prices over time, we chose a specialized type of neural network
called Long Short-Term Memory (LSTM). Unlike basic neural networks, LSTMs are great at
understanding patterns in sequences of data, making them a good fit for time series forecasting,
where past stock prices affect future ones.
LSTMs are especially handy because they can capture long-term relationships and handle the
complexities of stock price movements. Traditional neural networks often struggle with these
challenges, but LSTMs use memory cells and gates to manage information flow, making them
better at learning from historical data.
One big advantage of LSTMs is their ability to adapt to different lengths of input sequences,
which matches well with the variable nature of stock price data. By learning from past opening
and closing prices, LSTMs can uncover patterns that help make more accurate predictions.
We chose LSTM for its ability to effectively understand and use the patterns in stock price data
over time. Its design makes it a strong tool for predicting stock prices, aligning well with the
changing and connected nature of financial markets.

5. Discussion about the conclusions documenting the results and probabilities


produced by the constructed Neural Network showcasing whether the achieved
results are satisfactory or not.

The results from our Neural Network provide useful information about how well it predicts stock
prices. Let's break down the key numbers:
1. Test Loss (0.0088): This shows how much our predictions differ from the actual stock prices.
A lower test loss is better, and our value is quite low, indicating good accuracy.
2. Mean Absolute Error (MAE) (0.0788): This measures the average difference between our
predicted and actual stock prices. A lower MAE is better, and our value suggests our predictions
are generally close to the real values.
3. Mean Squared Error (MSE) (0.0088): This calculates the average of the squared differences
between predicted and actual values. A lower MSE is better, indicating our model is doing well
in minimizing errors.
4. R^2 Score (0.5458): This tells us how well our model explains the variability in stock prices.
While a perfect score is 1, our 0.5458 suggests our model reasonably captures patterns in the
data.
Our Neural Network shows promise in predicting stock prices, with low test loss and MAE. The
R^2 score indicates decent performance in explaining the data's variability.

Dataset Link:
https://www.kaggle.com/datasets/arashnic/time-series-forecasting-with-yahoo-stock-price

You might also like