Comments (8)
Yeah I completely understand what you're saying. To be honest, if you check trending repos everyday you probably have a better idea of what's ideal for a readme than me, so I think I'll take you up on the idea of including the extra future predictions in the plot. I had no idea this was going to be seen by as many people as it did when I first posted it haha, so I appreciate the feedback!
from hmms_stock_market.
Regarding the plot, it could potentially be a bug and the graph is including the 8 extra values. When you open the file named "/companyname_HMM_Predictions_mse.xlsx, are the values at the bottom of the table in the future or up until the day/ day before you ran the code? The plot is based off of those outputs and looking into it will determine if it's a bug or not. To me it looks like the plot has included 01/01/2021 on the x axis but hasn't reached that point for either line. Also 8 days into the future from the 15th wouldn't reach the 1st.
Regarding the metrics part, sorry it doesn't look that clear, I'll explain it, let me know if you understand and how you think it should be reworded?
The model predicts the closing price of a stock given the opening price. For historical data the current opening price is fed in and the close price is predicted. For the future predictions ( -f 8), predicted values are fed into the model one day at a time so that the close prices for the next 8 days can be created and stored. The reason we predict historical data is to get a metric for the quality of the model that cannot be obtained (in that moment) for future predictions as there is no true data to compare the predictions to. If the MSE produced by a model trained on data for 2 years is high, something like 50.5, you'd know to ignore the future predictions generated by that model. In contrast, if the MSE is low, the future predictions are (slightly) more validated.
from hmms_stock_market.
For command written in first post:
python stock_analysis.py -n AAPL -s 2018-01-01 -e 2020-12-15 -o ./appl_test/ -p True -f 8 -m True
AAPL_HMM_Prediction_3.853992.xlsx
shows values up until 2020-12-15.
AAPL_HMM_Predictions_8_days_in_future.xlsx
shows values into the future.
No file with _mse.xlsx ...
I guess I expected "Actual_Close" to be real close stock data. So the line should never be going into the future, and would be -f X amount of days shorter than the prediction line.
So, with the above command, I expected that the graph for "Actual_Close" would not extend past "-e 2020-12-15".
Or is this not what the graph is representing/am I completely missing something? Do you follow what I am saying? :D
I don't know that you should re-word anything because I don't understand it, ha. I have very little knowledge in this area. I certainly got more out of what you just said, but, I am confused by:
For historical data the current opening price is fed in and the close price is predicted. For the future predictions ( -f 8), predicted values are fed into the model one day at a time so that the close prices for the next 8 days can be created and stored.
current opening price meaning.. actual real info from past days.. or no?
...I feel like I should just try to understand what the code is doing/means. Maybe disregard this last part, ha... perhaps I'll be able to ask a better question (or answer it myself), as I dig into what is going on.
This, however, does make me understand it a little better:
The reason we predict historical data is to get a metric for the quality of the model that cannot be obtained (in that moment) for future predictions
Main thing I feel like there is "something wrong" --is that the predicted (graph rendered) is so close to actual values. Then seeing that the "actual values" ("Actual_close") extends into the future, really makes me think graph is not accurate.
from hmms_stock_market.
Sorry, I should have been clearer, 3.853992 = the MSE score. That's what I meant when I said "/companyname_HMM_Predictions_mse.xlsx". So you're right, actual close is in fact the real close stock data. It isn't going into the future, the plot is generated by the same data that you find in the "AAPL_HMM_Prediction_3.853992.xlsx" file, i.e. data up until 2020-12-15. So the plot is behaving as you're expecting: actual close represents the real close prices, and the final point on the plot is 2020-12-15.
Regarding the current opening price for future predictions, that is set by the previous days predicted close price. For these future prices the close price is predicted for the most recent day (in this case the 15th), then that close price is fed forward as the 16th's opening price, and the close price for the 16th is predicted (as any other day would be) and so on until "-f" days are reached. Unfortunately, this isn't a perfect representation of real life as day n's close price is not always equal to day n + 1's opening price due to out of hours changes in price that are the result of futures trading. There's potential for me to include these overnight changes due to futures trading at some point in the future, but it isn't currently part of the code.
To summarise, the plot is generated from the same data you see in AAPL_HMM_Prediction_3.853992.xlsx, and you are correct in thinking that actual close = real close stock data. The plot does not include future predictions, I guess it is just hard to discern where exactly it ends visually.
from hmms_stock_market.
In the graph I posted, the predicted line (red) actually looks shorter than the actual close line (blue). Shouldn't the predicted line (red) extend further than the actual_close line (blue)??
Are you saying--it does, but graph resolution is so--low, that it can't be discerned from it?
...I realized that's probably what you meant with _MSE shortly before seeing your response. Sorry!
from hmms_stock_market.
To me it looks like they end at the same point. I would advise checking the "AAPL_HMM_Prediction_3.853992.xlsx" file and seeing if the final date has a populated entry for the predicted close column. If it does then that is what you are seeing in the plot as it is made from the same dataframe that becomes that excel document.
You're right in thinking that the predicted close should extend beyond the actual close, if I were to include the -f predictions. They arent included in the plot, or in the "AAPL_HMM_Prediction_3.853992.xlsx" spreadsheet as there are no real prices (at the time of generation) to compare them to. I could add them to the plot, do you think that would be useful? My thinking was that the plot isn't detailed enough to provide the exact figures, so it'll be better for a user to just look at the future predictions spreadsheet than try to work out their values by looking at the graph.
from hmms_stock_market.
Just as a user that checks everyday trending repos--graphics are always exciting to see in a project because they show what the app does.
I was expecting, when I tested it out myself, that the prediction line would extend into the future, then I would anxiously wait for time to pass and see if it was close to the graph.
(Sidenote: I then realized I could just test this in the past though. For example have the program calculate 2018-01-01 -e 2020-12-05, extend by 8 days, and just see how it performed VS. real values of 12-05 through 12-13).
I get what you are saying though that graph isn't good to get actual values from.
I don't know, I just figured that since this is something that can predict future prices, that when viewing generated graph--it would have displayed line extending into the future.
from hmms_stock_market.
Congrats on your repo's success! ;)
So, I think, in summary, I was completely wrong that the graph was showing values into the future. My original thinking was that the prediction line would extend into the future (and past the "actual_close" line), so seeing the lines going up to the same date (and with resolution of graph it not being real clear about stop date)--I assumed, wrongly, that graph was drawing lines into the future.
If I am wrong about any of that, please let me know! Feel free to close issue.
from hmms_stock_market.
Related Issues (8)
- ValueError: Input contains NaN issue from total_data = np.row_stack((previous_data_features, possible_outcome)) HOT 1
- Unable to download data from Yahoo Finance
- Pre-installation
- Using "f-Strings"
- is there a wrong in line 114? HOT 1
- i want to ask about the Accuracy about the model HOT 1
- Import data from csv or xls instead of yahoo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hmms_stock_market.