• bitcoinBitcoin(BTC)$80,488.004.30%
  • ethereumEthereum(ETH)$2,419.356.46%
  • tetherTether(USDT)$1.000.05%
  • binancecoinBNB(BNB)$718.403.26%
  • rippleXRP(XRP)$1.303.41%
  • usd-coinUSDC(USDC)$1.000.02%
  • solanaSolana(SOL)$95.763.64%
  • tronTRON(TRX)$0.319328-0.89%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.051.53%
  • zcashZcash(ZEC)$1,289.616.00%
  • HyperliquidHyperliquid(HYPE)$84.210.31%
  • dogecoinDogecoin(DOGE)$0.0768993.14%
  • moneroMonero(XMR)$638.741.64%
  • USDSUSDS(USDS)$1.000.02%
  • whitebitWhiteBIT Coin(WBT)$77.864.95%
  • chainlinkChainlink(LINK)$11.394.39%
  • leo-tokenLEO Token(LEO)$9.340.39%
  • cardanoCardano(ADA)$0.1965884.38%
  • stellarStellar(XLM)$0.1675014.28%
  • bitcoin-cashBitcoin Cash(BCH)$280.502.62%
  • nearNEAR Protocol(NEAR)$4.004.51%
  • uniswapUniswap(UNI)$7.666.79%
  • daiDai(DAI)$1.000.02%
  • Ethena USDeEthena USDe(USDE)$1.000.06%
  • litecoinLitecoin(LTC)$56.184.66%
  • RainRain(RAIN)$0.005969-9.55%
  • CantonCanton(CC)$0.0990623.05%
  • avalanche-2Avalanche(AVAX)$8.733.48%
  • suiSui(SUI)$0.934.91%
  • USD1USD1(USD1)$1.000.06%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.170.11%
  • tether-goldTether Gold(XAUT)$4,071.763.66%
  • hedera-hashgraphHedera(HBAR)$0.0724865.16%
  • quant-networkQuant(QNT)$202.986.30%
  • Global DollarGlobal Dollar(USDG)$1.000.02%
  • shiba-inuShiba Inu(SHIB)$0.0000053.20%
  • BittensorBittensor(TAO)$235.775.28%
  • paypal-usdPayPal USD(PYUSD)$1.000.02%
  • crypto-com-chainCronos(CRO)$0.0519804.17%
  • Ripple USDRipple USD(RLUSD)$1.000.01%
  • EthenaEthena(ENA)$0.1806505.45%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.15-0.14%
  • okbOKB(OKB)$110.823.30%
  • Circle USYCCircle USYC(USYC)$1.140.01%
  • pepePepe(PEPE)$0.0000051.81%
  • aaveAave(AAVE)$131.684.59%
  • OndoOndo(ONDO)$0.4084476.02%
  • Pump.funPump.fun(PUMP)$0.004281-0.33%
  • MemeCoreMemeCore(M)$0.84-2.33%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

A Coding Guide to Build Flexible Multi-Model Workflows in GluonTS with Synthetic Data, Evaluation, and Advanced Visualizations

August 24, 2025
in AI & Technology
Reading Time: 3 mins read
A A
A Coding Guide to Build Flexible Multi-Model Workflows in GluonTS with Synthetic Data, Evaluation, and Advanced Visualizations
ShareShareShareShareShare
def plot_advanced_forecasts(test_data, forecasts_dict, series_idx=0):
   """Advanced plotting with multiple models and uncertainty bands"""
   fig, axes = plt.subplots(2, 2, figsize=(15, 10))
   fig.suptitle('Advanced GluonTS Forecasting Results', fontsize=16, fontweight="bold")
  
   if not forecasts_dict:
       fig.text(0.5, 0.5, 'No successful forecasts to display',
               ha="center", va="center", fontsize=20)
       return fig
  
   if series_idx < len(test_data.label):
       ts_label = test_data.label[series_idx]
       ts_input = test_data.input[series_idx]['target']
      
       colors = ['blue', 'red', 'green', 'purple', 'orange']
      
       ax1 = axes[0, 0]
       ax1.plot(range(len(ts_input)), ts_input, 'k-', label="Historical", alpha=0.8, linewidth=2)
       ax1.plot(range(len(ts_input), len(ts_input) + len(ts_label)),
               ts_label, 'k--', label="True Future", alpha=0.8, linewidth=2)
      
       for i, (name, forecasts) in enumerate(forecasts_dict.items()):
           if series_idx < len(forecasts):
               forecast = forecasts[series_idx]
               forecast_range = range(len(ts_input), len(ts_input) + len(forecast.mean))
              
               color = colors[i % len(colors)]
               ax1.plot(forecast_range, forecast.mean,
                       color=color, label=f'{name} Mean', linewidth=2)
              
               try:
                   ax1.fill_between(forecast_range,
                                  forecast.quantile(0.1), forecast.quantile(0.9),
                                  alpha=0.2, color=color, label=f'{name} 80% CI')
               except:
                   pass 
      
       ax1.set_title('Multi-Model Forecasts Comparison', fontsize=12, fontweight="bold")
       ax1.legend()
       ax1.grid(True, alpha=0.3)
       ax1.set_xlabel('Time Steps')
       ax1.set_ylabel('Value')
      
       ax2 = axes[0, 1]
       if all_forecasts:
           first_model = list(all_forecasts.keys())[0]
           if series_idx < len(all_forecasts[first_model]):
               forecast = all_forecasts[first_model][series_idx]
               ax2.scatter(ts_label, forecast.mean, alpha=0.7, s=60)
              
               min_val = min(min(ts_label), min(forecast.mean))
               max_val = max(max(ts_label), max(forecast.mean))
               ax2.plot([min_val, max_val], [min_val, max_val], 'r--', alpha=0.8)
              
               ax2.set_title(f'Prediction vs Actual - {first_model}', fontsize=12, fontweight="bold")
               ax2.set_xlabel('Actual Values')
               ax2.set_ylabel('Predicted Values')
               ax2.grid(True, alpha=0.3)
      
       ax3 = axes[1, 0]
       if all_forecasts:
           first_model = list(all_forecasts.keys())[0]
           if series_idx < len(all_forecasts[first_model]):
               forecast = all_forecasts[first_model][series_idx]
               residuals = ts_label - forecast.mean
               ax3.hist(residuals, bins=15, alpha=0.7, color="skyblue", edgecolor="black")
               ax3.axvline(x=0, color="r", linestyle="--", linewidth=2)
               ax3.set_title(f'Residuals Distribution - {first_model}', fontsize=12, fontweight="bold")
               ax3.set_xlabel('Residuals')
               ax3.set_ylabel('Frequency')
               ax3.grid(True, alpha=0.3)
      
       ax4 = axes[1, 1]
       if evaluation_results:
           metrics = ['MASE', 'sMAPE'] 
           model_names = list(evaluation_results.keys())
           x = np.arange(len(metrics))
           width = 0.35
          
           for i, model_name in enumerate(model_names):
               values = [evaluation_results[model_name].get(metric, 0) for metric in metrics]
               ax4.bar(x + i*width, values, width,
                      label=model_name, color=colors[i % len(colors)], alpha=0.8)
          
           ax4.set_title('Model Performance Comparison', fontsize=12, fontweight="bold")
           ax4.set_xlabel('Metrics')
           ax4.set_ylabel('Value')
           ax4.set_xticks(x + width/2 if len(model_names) > 1 else x)
           ax4.set_xticklabels(metrics)
           ax4.legend()
           ax4.grid(True, alpha=0.3)
       else:
           ax4.text(0.5, 0.5, 'No evaluation\nresults available',
                   ha="center", va="center", transform=ax4.transAxes, fontsize=14)
  
   plt.tight_layout()
   return fig


if all_forecasts and test_data.label:
   print("📈 Creating advanced visualizations...")
   fig = plot_advanced_forecasts(test_data, all_forecasts, series_idx=0)
   plt.show()
  
   print(f"\n🎉 Tutorial completed successfully!")
   print(f"📊 Trained {len(trained_models)} model(s) on {len(df.columns) if 'df' in locals() else 10} time series")
   print(f"🎯 Prediction length: 30 days")
  
   if evaluation_results:
       best_model = min(evaluation_results.items(), key=lambda x: x[1]['MASE'])
       print(f"🏆 Best performing model: {best_model[0]} (MASE: {best_model[1]['MASE']:.4f})")
  
   print(f"\n🔧 Environment Status:")
   print(f"  PyTorch Support: {'✅' if TORCH_AVAILABLE else '❌'}")
   print(f"  MXNet Support: {'✅' if MX_AVAILABLE else '❌'}")
  
else:
   print("⚠️  Creating demonstration plot with synthetic data...")
  
   fig, ax = plt.subplots(1, 1, figsize=(12, 6))
  
   dates = pd.date_range('2020-01-01', periods=100, freq='D')
   ts = 100 + np.cumsum(np.random.normal(0, 2, 100)) + 20 * np.sin(np.arange(100) * 2 * np.pi / 30)
  
   ax.plot(dates[:70], ts[:70], 'b-', label="Historical Data", linewidth=2)
   ax.plot(dates[70:], ts[70:], 'r--', label="Future (Example)", linewidth=2)
   ax.fill_between(dates[70:], ts[70:] - 5, ts[70:] + 5, alpha=0.3, color="red")
  
   ax.set_title('GluonTS Probabilistic Forecasting Example', fontsize=14, fontweight="bold")
   ax.set_xlabel('Date')
   ax.set_ylabel('Value')
   ax.legend()
   ax.grid(True, alpha=0.3)
  
   plt.tight_layout()
   plt.show()
  
   print("\n📚 Tutorial demonstrates advanced GluonTS concepts:")
   print("  • Multi-series dataset generation")
   print("  • Probabilistic forecasting")
   print("  • Model evaluation and comparison")
   print("  • Advanced visualization techniques")
   print("  • Robust error handling")

Credit: Source link

YOU MAY ALSO LIKE

Snap Has More Than 30 Million Paid Subscribers Across Snapchat+ And Other Plans

Atmospheric AI Secures $10M Seed for Procurement Modeling Push – Unite.AI

ShareTweetSendSharePin

Related Posts

Snap Has More Than 30 Million Paid Subscribers Across Snapchat+ And Other Plans
AI & Technology

Snap Has More Than 30 Million Paid Subscribers Across Snapchat+ And Other Plans

November 4, 2026
Atmospheric AI Secures M Seed for Procurement Modeling Push – Unite.AI
AI & Technology

Atmospheric AI Secures $10M Seed for Procurement Modeling Push – Unite.AI

November 4, 2026
Perplexity Adds Live Web Grounding to Its Decisions API – Unite.AI
AI & Technology

Perplexity Adds Live Web Grounding to Its Decisions API – Unite.AI

November 4, 2026
Pangram Expands Its AI Detection Tools To Video And Images
AI & Technology

Pangram Expands Its AI Detection Tools To Video And Images

November 4, 2026
Next Post
McDonald’s is putting the “value” back in value meals

McDonald’s is putting the “value” back in value meals

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Meet the Press NOW — October 2

Meet the Press NOW — October 2

November 2, 2026
Brewers vs. Rays live updates, lineups, where to watch: Milwaukee gets another shot at first World Series title after Rays' walk-off win in Game 4 – Yahoo Sports

Brewers vs. Rays live updates, lineups, where to watch: Milwaukee gets another shot at first World Series title after Rays' walk-off win in Game 4 – Yahoo Sports

October 29, 2026
UFC Fight Night 292 live updates: Renato Moicano vs. Tom Nolan results – MMA Junkie

UFC Fight Night 292 live updates: Renato Moicano vs. Tom Nolan results – MMA Junkie

November 1, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!