Update README.md
Browse files
README.md
CHANGED
|
@@ -1,83 +1,79 @@
|
|
| 1 |
-
---
|
| 2 |
-
# For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
|
| 3 |
-
# Doc / guide: https://huggingface.co/docs/hub/model-cards
|
| 4 |
-
{}
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
# Model Card for Model ID
|
| 8 |
-
|
| 9 |
-
The Hybrid Image-Numerical Stock Prediction Model is a multi-input neural network designed to predict binary stock price movements (up/down) based on historical chart images and technical indicators. It processes both image data (stock charts) and numerical data (technical indicators like RSI, MACD, Bollinger Bands, ATR, and OBV) to make predictions.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
|
| 13 |
-
|
| 14 |
-
## Uses
|
| 15 |
-
|
| 16 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 17 |
-
|
| 18 |
-
### Direct Use
|
| 19 |
-
|
| 20 |
-
The model can be used for predicting short-term stock price movements based on historical data. It is intended for use in financial analysis when combined with other tools and strategies.
|
| 21 |
-
|
| 22 |
-
## Bias, Risks, and Limitations
|
| 23 |
-
|
| 24 |
-
The model may exhibit biases based on the training dataset's characteristics. It may not perform well during sudden market shifts caused by external factors. Users should be cautious about over-reliance on the model's predictions without additional analysis.
|
| 25 |
-
|
| 26 |
-
### Recommendations
|
| 27 |
-
|
| 28 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
|
|
|
|
| 34 |
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
### Training Data
|
| 39 |
-
|
| 40 |
-
The model was trained on the Kaylah072001/Stock_Graphs_Dataset, which includes stock chart images and corresponding price data. Technical indicators were extracted using the ta library.
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
### Training Procedure
|
| 45 |
-
|
| 46 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 47 |
-
|
| 48 |
-
#### Preprocessing [optional]
|
| 49 |
|
| 50 |
-
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
###
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
Optimizer: Adam
|
| 57 |
-
Loss function: Binary crossentropy
|
| 58 |
-
Metrics: Accuracy, AUC-ROC
|
| 59 |
-
Cross-validation: 5-fold stratified k-fold
|
| 60 |
|
|
|
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
|
| 65 |
-
##
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
|
| 71 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
|
|
|
| 82 |
|
|
|
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
# Stock Classification Model
|
| 3 |
|
| 4 |
+
This repository contains The Hybrid Image-Numerical Stock Prediction Model is a multi-input neural network designed to predict binary stock price movements (up/down) based on historical chart images and technical indicators. It processes both image data (stock charts) and numerical data (technical indicators like RSI, MACD, Bollinger Bands, ATR, and OBV) to make predictions.
|
| 5 |
|
| 6 |
+
---
|
| 7 |
|
| 8 |
+
## Features 🐾
|
| 9 |
+
- **High Accuracy**: Achieves a **test accuracy of 83.43%**!
|
| 10 |
|
| 11 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
## Performance Metrics 📊
|
| 14 |
|
| 15 |
+
### Final Results:
|
| 16 |
+
- **Test Accuracy**: `91.35%`
|
| 17 |
+
- **Validation Accuracy**: `86.89%`
|
| 18 |
+
- **Training Accuracy**: `99.89%`
|
| 19 |
|
| 20 |
+
### Confusion Matrix Visualization 🎯
|
| 21 |
+

|
| 22 |
|
| 23 |
+
This confusion matrix gives a detailed view of the classification performance for each Pokémon class. Misclassifications are represented along the off-diagonal cells.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
---
|
| 26 |
|
| 27 |
+
## Dataset 📂
|
| 28 |
+
- **Source**: Stock graph images from opensource API yfinance.
|
| 29 |
+
- **Structure**:
|
| 30 |
+
- `images/`: Contains all Pokémon images.
|
| 31 |
+
- `pokemon.csv`: Metadata linking each image to its respective Pokémon and class labels.
|
| 32 |
|
| 33 |
+
---
|
| 34 |
|
| 35 |
+
## Model Details 🧠
|
| 36 |
+
- **Architecture**: Fine-tuned **ResNet101**.
|
| 37 |
+
- **Optimizer**: Adam with learning rate scheduling.
|
| 38 |
+
- **Loss Function**: Cross-Entropy Loss.
|
| 39 |
|
| 40 |
+
---
|
| 41 |
|
| 42 |
+
## Usage 🚀
|
| 43 |
|
| 44 |
+
### Loading the Model
|
| 45 |
+
```python
|
| 46 |
+
import torch
|
| 47 |
+
from tensorflow.keras.models import Model
|
| 48 |
+
import pickle
|
| 49 |
|
| 50 |
+
# Load the model
|
| 51 |
+
model = Model(inputs=[img_input, num_input], outputs=output)
|
| 52 |
+
num_features = model.fc.in_features
|
| 53 |
+
model.fc = torch.nn.Linear(num_features, 2)
|
| 54 |
+
model.load_state_dict(torch.load('stock_prediction_model.h5'))
|
| 55 |
+
model.eval()
|
| 56 |
|
| 57 |
+
# Load label mapping
|
| 58 |
+
with open('label_mapping.pkl', 'rb') as f:
|
| 59 |
+
label_mapping = pickle.load(f)
|
| 60 |
|
| 61 |
+
```
|
| 62 |
|
| 63 |
+
### Making Predictions
|
| 64 |
+
```python
|
| 65 |
+
from PIL import Image
|
| 66 |
+
from tensorflow.keras.preprocessing import transforms
|
| 67 |
|
| 68 |
+
# Define transforms
|
| 69 |
+
val_transform = transforms.Compose([
|
| 70 |
+
transforms.Resize((224, 224)),
|
| 71 |
+
transforms.ToTensor(),
|
| 72 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
| 73 |
+
])
|
| 74 |
|
| 75 |
+
```
|
| 76 |
|
| 77 |
+
---
|
| 78 |
|
| 79 |
+
Feel free to explore and use the model. Contributions are welcome! 🙌
|