π Hugging Face Spaces Setup Guide
Overview
This guide explains how to create a Hugging Face Space for interactive testing of the StoxChai NSE Stock Prediction Models.
What We're Creating
- Interactive Web App: Users can test models directly on Hugging Face
- Real-time Predictions: Input 16 features and get stock price predictions
- Model Comparison: See predictions from all 8 models side-by-side
- Beautiful UI: Modern Gradio interface with gradients and styling
Step-by-Step Setup
1. Create Hugging Face Space
- Go to huggingface.co/spaces
- Click "Create new Space"
- Choose settings:
- Owner:
thoutam - Space name:
stoxchai-stock-predictor - Space SDK: Gradio
- Space hardware: CPU (free tier)
- License: MIT
- Owner:
2. Upload Files
Upload these files to your Space:
Core Files:
app.py- Main Gradio applicationrequirements_app.txt- Python dependencies- All 8 trained models (
.joblibfiles) feature_scaler.joblib- Feature scaler
Documentation:
README.md- Main documentationmodel_card.md- Model information- Generated visualization images
3. Configure Space
The Space will automatically:
- Install dependencies from
requirements_app.txt - Run
app.pyas the main application - Create a web interface at
https://huggingface.co/spaces/thoutam/stoxchai-stock-predictor
Features of the Interactive App
π― Model Testing
- 8 Models Available: RandomForest, GradientBoosting, LinearRegression, Ridge, Lasso, SVR, XGBoost, LightGBM
- Real-time Predictions: Get instant stock price predictions
- Feature Input: 16 input fields for technical indicators
- Sample Data: Pre-filled with example values
π Results Display
- Individual Predictions: See results from each model
- Ensemble Prediction: Average of all successful predictions
- Error Handling: Graceful handling of prediction failures
- Formatted Output: Clean, readable results
π¨ User Interface
- Modern Design: Beautiful gradients and styling
- Responsive Layout: Works on desktop and mobile
- Intuitive Controls: Easy-to-use input forms
- Helpful Descriptions: Clear feature explanations
Usage Instructions
For Users
- Visit the Space: Navigate to your Hugging Face Space URL
- Input Features: Enter 16 technical indicators
- Select Model: Choose which model to use
- Get Prediction: Click "Make Prediction" button
- Compare Results: View predictions from all models
For Developers
- Clone the Space: Download the Space repository
- Modify App: Customize the Gradio interface
- Add Features: Extend functionality as needed
- Deploy Updates: Push changes to automatically update
Technical Details
Dependencies
- Gradio: Web interface framework
- Scikit-learn: Machine learning models
- Joblib: Model persistence
- NumPy/Pandas: Data processing
Model Loading
- Models are loaded when the app starts
- Feature scaler is applied automatically
- 5-day lookback sequences are created dynamically
- Error handling for missing model files
Input Validation
- Checks for exactly 16 features
- Validates numeric input types
- Handles missing or invalid data gracefully
Customization Options
UI Styling
- Modify CSS in the
create_interface()function - Change color schemes and gradients
- Adjust layout and spacing
- Add custom themes
Model Selection
- Add/remove models from the dropdown
- Change default model selection
- Add model descriptions and metadata
Feature Inputs
- Modify feature names and descriptions
- Add input validation rules
- Change default sample values
- Add feature help text
Troubleshooting
Common Issues
- Models Not Loading: Check file paths and permissions
- Prediction Errors: Verify input feature format
- Memory Issues: Use smaller models or CPU optimization
- Dependency Errors: Check requirements.txt compatibility
Debug Mode
- Enable
show_error=Truein app.launch() - Check Space logs for error messages
- Test locally before deploying
Benefits of Hugging Face Spaces
For Users
- No Installation: Test models directly in browser
- Instant Access: No need to download or setup
- Cross-platform: Works on any device with internet
- Always Updated: Latest models and features
For Developers
- Easy Deployment: Automatic deployment from Git
- Scalable: Handles multiple users simultaneously
- Integrated: Part of Hugging Face ecosystem
- Community: Share with AI researchers worldwide
Next Steps
- Create the Space following the setup guide
- Upload all files including models and app
- Test the interface with sample data
- Share the Space with your community
- Collect feedback and iterate improvements
π Your interactive stock prediction app will be live on Hugging Face Spaces!
Users worldwide can now test your NSE prediction models without any setup or installation.