SmartCart is a state-of-the-art machine learning project that leverages LSTM neural networks and real-time data from the Yahoo Finance API to predict stock prices with up to 92% accuracy.
- 📈 LSTM-based deep learning for time series forecasting
- 🔗 Seamless Yahoo Finance API integration
- 🎯 92% accuracy on test data
- 🛠️ Easily extendable for other financial instruments
- Data Collection: Fetches historical stock data using Yahoo Finance API
- Preprocessing: Cleans and prepares data for training
- Model Training: Trains an LSTM model on the processed data
- Prediction: Uses the trained model to forecast future stock prices
- Python 3.8+
- pip
# Clone the repository
git clone https://github.com/yourusername/SmartCart.git
cd SmartCart
# Install dependencies
pip install -r requirements.txt# Run the main script
python main.pyYou can also use the SmartCart web interface:
python app.pyThen open your browser and go to http://localhost:5050 (or the port you choose) to use the web UI for predictions.
You can try SmartCart instantly on Render: https://smartcart-xuqj.onrender.com
You can also run SmartCart using Docker:
docker build -t smartcart-app .
docker run -p 5050:5000 smartcart-appThen visit http://localhost:5050
PORT: Set this to change the port (default is 5000, but you may need to use another, e.g. 5050)PORT=5050 python app.py
| Feature | Description |
|---|---|
| LSTM Model | Deep learning for time series forecasting |
| Yahoo Finance API | Real-time stock data fetching |
| Web UI | User-friendly prediction interface |
| CLI | Command-line interface for predictions |
| Docker Support | Easy containerized deployment |
| Model Evaluation | Built-in accuracy evaluation example |
| Extendable | Adaptable to other financial instruments |
Description: Predict future stock prices.
Request:
ticker(string, required): Stock ticker symbol (e.g., AAPL)days(int, optional): Number of days to predict (default: 7)
Response:
predictions: List of predicted priceserror: Error message if request fails
Example:
curl -X POST -F "ticker=AAPL" -F "days=7" http://localhost:5050/predictfrom smartcart import SmartCart
model = SmartCart('AAPL')
model.train()
prediction = model.predict(days=7)
print(prediction)- Achieves up to 92% accuracy on historical stock data (see below for how to evaluate)
- Performance may vary depending on the stock and time period
To evaluate the model's accuracy on your data:
from smartcart.model import SmartCart
model = SmartCart('AAPL')
model.fetch_data()
model.prepare_data()
model.build_model()
model.train()
# Evaluate on training data (for demo purposes)
preds = model.model.predict(model.trainX)
from sklearn.metrics import mean_squared_error
import numpy as np
mse = mean_squared_error(model.trainY, preds.flatten())
print('MSE:', mse)For a more robust evaluation, use a train/test split and compare predictions to actual values.
MIT License
For questions or support, please open an issue or contact [email protected]
