Spaces:
Sleeping
Sleeping
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,170 +1,48 @@
|
|
| 1 |
-
# π International Trade Flow Predictor with AI Assistant π’ππ€
|
| 2 |
-
|
| 3 |
-
[](https://github.com/jomasego/international_trade_predictions/actions/workflows/deploy-space.yml)
|
| 4 |
-
|
| 5 |
-
Welcome to the **International Trade Flow Predictor**! π
|
| 6 |
-
|
| 7 |
-
A fun, interactive web app to explore, analyze, and predict international trade flows using real data and machine learning. Now with AI-powered trade assistance! Built with Flask, vanilla JS, and a dash of data science magic. π§ββοΈβ¨
|
| 8 |
-
|
| 9 |
-
[](https://huggingface.co/spaces/jomasego/ai-trade-assistant)
|
| 10 |
-
|
| 11 |
---
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
- Bilateral Trade βοΈ
|
| 21 |
-
- Data Download πΎ
|
| 22 |
-
- ML Prediction π€
|
| 23 |
-
|
| 24 |
-
- **Data Visualizations** π
|
| 25 |
-
- Tables, charts, and downloadable CSVs everywhere!
|
| 26 |
-
- Interactive country/product selection
|
| 27 |
-
- All powered by UN COMTRADE, WTO, and World Bank data
|
| 28 |
-
|
| 29 |
-
- **Machine Learning Models** π§
|
| 30 |
-
- Linear Regression
|
| 31 |
-
- XGBoost
|
| 32 |
-
- LSTM (Deep Learning)
|
| 33 |
-
- Predict future trade flows and visualize both historical and predicted values!
|
| 34 |
-
|
| 35 |
-
- **Modern, Accessible UI**
|
| 36 |
-
- Keyboard navigation, ARIA attributes, and a clean look
|
| 37 |
-
- No frontend frameworks, just pure JS!
|
| 38 |
-
|
| 39 |
-
- **AI Trade Assistant** π€
|
| 40 |
-
- Powered by Google Gemma-2b
|
| 41 |
-
- Interactive chat interface for trade data queries
|
| 42 |
-
- HS code explanation and interpretation
|
| 43 |
-
- Trade pattern recommendations
|
| 44 |
-
- Context-aware responses to help navigate the application
|
| 45 |
-
|
| 46 |
---
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
You have two options for deploying this application:
|
| 51 |
-
|
| 52 |
-
### Option 1: Full Web Application with Integrated AI Assistant
|
| 53 |
-
|
| 54 |
-
This option gives you the complete Trade Flow Predictor application with the AI Assistant directly integrated into the application interface.
|
| 55 |
-
|
| 56 |
-
1. **Clone the repo:**
|
| 57 |
-
```bash
|
| 58 |
-
git clone https://github.com/jomasego/international_trade_predictions.git
|
| 59 |
-
cd international_trade_predictions/comtrade_predictions
|
| 60 |
-
```
|
| 61 |
-
|
| 62 |
-
2. **Set up environment variable:**
|
| 63 |
-
Create a `.env` file in the root directory with your Hugging Face API token:
|
| 64 |
-
```
|
| 65 |
-
HUGGINGFACE_API_TOKEN=your_token_here
|
| 66 |
-
```
|
| 67 |
-
This token is required to access the Google Gemma-2b model via Hugging Face Inference API.
|
| 68 |
-
|
| 69 |
-
3. **Install dependencies:**
|
| 70 |
-
```bash
|
| 71 |
-
pip install -r requirements.txt
|
| 72 |
-
```
|
| 73 |
-
|
| 74 |
-
4. **Launch the app:**
|
| 75 |
-
```bash
|
| 76 |
-
python app.py
|
| 77 |
-
```
|
| 78 |
-
|
| 79 |
-
5. **Open your browser:**
|
| 80 |
-
- Go to [http://127.0.0.1:5000](http://127.0.0.1:5000)
|
| 81 |
-
- Navigate to the AI Assistant tab to interact with the integrated assistant
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
This option deploys just the AI Assistant component as a separate application on Hugging Face Spaces. This is useful if you only want to provide the AI Assistant functionality without the full application.
|
| 86 |
-
|
| 87 |
-
1. **Use our existing space:**
|
| 88 |
-
- Visit [AI Trade Assistant](https://huggingface.co/spaces/jomasego/ai-trade-assistant) to use the pre-deployed version
|
| 89 |
-
|
| 90 |
-
2. **OR deploy your own space:**
|
| 91 |
-
|
| 92 |
-
a. **Create a new Space** on Hugging Face with the Flask SDK
|
| 93 |
-
|
| 94 |
-
b. **Upload the files from the `clean-space` directory:**
|
| 95 |
-
- `app.py`
|
| 96 |
-
- `requirements.txt`
|
| 97 |
-
- `templates/index.html`
|
| 98 |
-
|
| 99 |
-
c. **Set up environment variable:**
|
| 100 |
-
- Add `HUGGINGFACE_API_TOKEN` to your space under Settings > Repository Secrets
|
| 101 |
-
|
| 102 |
-
d. **Your space will automatically deploy** and be accessible through the provided URL
|
| 103 |
-
|
| 104 |
-
### Option 3: Automatic GitHub Actions Deployment
|
| 105 |
-
|
| 106 |
-
This project is configured to automatically deploy to Hugging Face Spaces using GitHub Actions:
|
| 107 |
-
|
| 108 |
-
1. **One-time setup:**
|
| 109 |
-
- Add required secrets to your GitHub repository:
|
| 110 |
-
- `HF_TOKEN`: Your Hugging Face API token
|
| 111 |
-
- `SPACE_NAME`: Your desired Space name
|
| 112 |
-
- `HUGGINGFACE_API_TOKEN`: Same as your HF_TOKEN
|
| 113 |
-
|
| 114 |
-
2. **Automatic deployment:**
|
| 115 |
-
- Every push to the `main` branch triggers a deployment
|
| 116 |
-
- Your app will be available at: `https://huggingface.co/spaces/jomasego/[SPACE_NAME]`
|
| 117 |
-
|
| 118 |
-
3. **Manual triggering:**
|
| 119 |
-
- You can also manually trigger deployment from the GitHub Actions tab
|
| 120 |
-
|
| 121 |
-
### Using the AI Assistant
|
| 122 |
-
|
| 123 |
-
Regardless of which deployment option you choose:
|
| 124 |
|
| 125 |
-
|
| 126 |
-
2. Type your trade-related question in the chat input
|
| 127 |
-
3. Use specialized features:
|
| 128 |
-
- HS Code Lookup: Get detailed explanations of HS codes
|
| 129 |
-
- Trade Recommendations: Receive insights on trade patterns based on countries or product categories
|
| 130 |
|
| 131 |
-
|
| 132 |
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
-
- Quick lookups by country, year, commodity, and flow
|
| 137 |
-
- **Exports/Imports by Country:**
|
| 138 |
-
- See trade values for all countries in a given year/commodity
|
| 139 |
-
- **Exports/Imports by Product:**
|
| 140 |
-
- Explore top traded products for a country
|
| 141 |
-
- **Rankings:**
|
| 142 |
-
- Who are the top exporters/importers? Find out!
|
| 143 |
-
- **Bilateral Trade:**
|
| 144 |
-
- Analyze trade between any two countries
|
| 145 |
-
- **Data Download:**
|
| 146 |
-
- Custom CSV downloads for power users
|
| 147 |
-
- **Prediction (ML):**
|
| 148 |
-
- Select countries, commodity, and year, pick a model, and predict the future! See both historical and predicted values plotted together.
|
| 149 |
|
| 150 |
-
|
| 151 |
|
| 152 |
-
|
| 153 |
-
-
|
| 154 |
-
-
|
| 155 |
-
-
|
| 156 |
-
-
|
| 157 |
|
| 158 |
-
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
| 166 |
-
- [GitHub Issues](https://github.com/jomasego/international_trade_predictions/issues)
|
| 167 |
|
| 168 |
-
|
| 169 |
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Trade Flow Predictor
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
sdk_version: "1.0"
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# International Trade Flow Predictor with AI Assistant
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
Welcome to the **International Trade Flow Predictor**! π
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
A fun, interactive web app to explore, analyze, and predict international trade flows using real data and machine learning. Now with AI-powered trade assistance! Built with Flask, vanilla JS, and a dash of data science magic.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
## Features
|
| 19 |
|
| 20 |
+
- **Interactive Data Visualization**: Explore international trade data with various chart types and filters
|
| 21 |
+
- **Machine Learning Predictions**: Forecast future trade values using multiple ML models
|
| 22 |
+
- **AI Trade Assistant**: Get intelligent assistance with all your trade-related questions
|
| 23 |
+
- **Comprehensive Data Access**: Retrieve and analyze data from UN COMTRADE, WTO, and World Bank sources
|
| 24 |
|
| 25 |
+
## AI Assistant Capabilities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
The built-in AI Trade Assistant, powered by Google Gemma-2b via Hugging Face, can help you:
|
| 28 |
|
| 29 |
+
- Understand trade terminology and HS codes
|
| 30 |
+
- Explore interesting trade patterns
|
| 31 |
+
- Find specific trade data
|
| 32 |
+
- Interpret visualization results
|
| 33 |
+
- Provide insights about international trade
|
| 34 |
|
| 35 |
+
## Using the Application
|
| 36 |
|
| 37 |
+
1. Explore different tabs to access various features
|
| 38 |
+
2. Select countries, products, and years to visualize data
|
| 39 |
+
3. Try the machine learning predictions for future trade values
|
| 40 |
+
4. Chat with the AI Assistant for trade-related questions
|
| 41 |
|
| 42 |
+
## Privacy & Data Usage
|
| 43 |
|
| 44 |
+
This application does not collect any personal data. API usage is subject to fair use policies of the data sources (UN COMTRADE, WTO, World Bank).
|
|
|
|
| 45 |
|
| 46 |
+
## About
|
| 47 |
|
| 48 |
+
Created by JosΓ© MarΓa SeguΓ GΓ³mez-Olea. The AI component is powered by Google Gemma-2b through Hugging Face Inference API.
|