Views
No views yet
SurgeJointLoss): Fused with categorical Country Embeddings (nn.Embedding), this recurrent network is trained on a custom Huber + BCE objective. It acts as the "Precision Guard," heavily penalizing false alarms.| Predictive Horizon | Precision (False Alarm Guard) | Recall (Miss Rate) | F1-Score |
|---|---|---|---|
| Lead 1 (Next Month) | 0.96 | 0.96 | 0.96 |
| Lead 2 (2 Months Out) | 0.93 | 0.96 | 0.95 |
| Lead 3 (3 Months Out) | 0.92 | 0.94 | 0.93 |
| Lead 4 (4 Months Out) | 0.88 | 0.94 | 0.91 |
| Lead 5 (5 Months Out) | 0.83 | 0.94 | 0.88 |
| Lead 6 (6 Months Out) | 0.80 | 0.92 | 0.86 |
torch, scikit-learn, numpy, and joblib installed.MigrationSurgeEnsemble inference wrapper:1from inference import MigrationSurgeEnsemble
2
3# 1. Initialize the ensemble (points to the directory containing the .pth and .joblib files)
4predictor = MigrationSurgeEnsemble(models_dir=".")
5
6# 2. Provide the rolling 6-month historical data for a specific country
7# Format per month: [visa_volume, exchange_rate, news_sentiment_count]
8# Array structure: [T-6, T-5, T-4, T-3, T-2, T-1 (Current)]
9historical_scenario = [
10 [15000, 19.5, 45], # Lag 6
11 [16000, 19.8, 52], # Lag 5
12 [18500, 19.9, 70], # Lag 4
13 [22000, 20.3, 85], # Lag 3
14 [24000, 20.5, 110], # Lag 2
15 [31000, 21.0, 140] # Lag 1
16]
17
18# 3. Generate 6-month forward projections
19results = predictor.predict(country_name="Mexico", recent_6_months_data=historical_scenario)
20
21print(results['Ensemble Prediction Volume'])
22# Output: [36051.0, 38024.0, 41200.0, 43156.0, 44800.0, 41200.0]rf_lead_1.joblib -> rf_lead_6.joblib: The 6 independent Time Horizon Random Forest models.lstm.pth: PyTorch weights for the Recurrent Architecture targeting extreme spikes.transformer.pth: PyTorch weights for the Multi-Head Attention Architecture.scaler_x.joblib, scaler_y.joblib: StandardScaler fits to ensure incoming user inference data identically matches the normalized training bounds.country_map.json: Required dictionary mapping country names to categorical embedding IDs.