• bitcoinBitcoin(BTC)$84,060.00-0.28%
  • ethereumEthereum(ETH)$2,672.31-0.74%
  • tetherTether(USDT)$1.000.00%
  • binancecoinBNB(BNB)$777.640.68%
  • rippleXRP(XRP)$1.51-0.20%
  • usd-coinUSDC(USDC)$1.000.00%
  • solanaSolana(SOL)$121.720.80%
  • tronTRON(TRX)$0.3338870.11%
  • zcashZcash(ZEC)$1,575.44-4.24%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.06-0.38%
  • HyperliquidHyperliquid(HYPE)$90.41-2.50%
  • dogecoinDogecoin(DOGE)$0.0965050.37%
  • chainlinkChainlink(LINK)$14.03-0.05%
  • moneroMonero(XMR)$549.18-1.38%
  • whitebitWhiteBIT Coin(WBT)$83.85-0.29%
  • USDSUSDS(USDS)$1.000.01%
  • cardanoCardano(ADA)$0.2549461.44%
  • RainRain(RAIN)$0.012626-0.99%
  • leo-tokenLEO Token(LEO)$9.020.65%
  • stellarStellar(XLM)$0.2169791.10%
  • nearNEAR Protocol(NEAR)$5.305.24%
  • bitcoin-cashBitcoin Cash(BCH)$329.07-1.36%
  • uniswapUniswap(UNI)$9.64-2.60%
  • CantonCanton(CC)$0.1405983.58%
  • litecoinLitecoin(LTC)$70.23-2.17%
  • suiSui(SUI)$1.279.17%
  • Ethena USDeEthena USDe(USDE)$1.000.02%
  • avalanche-2Avalanche(AVAX)$10.861.12%
  • daiDai(DAI)$1.000.00%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.610.39%
  • USD1USD1(USD1)$1.00-0.01%
  • hedera-hashgraphHedera(HBAR)$0.0963964.08%
  • quant-networkQuant(QNT)$256.6859.25%
  • BittensorBittensor(TAO)$315.28-1.08%
  • shiba-inuShiba Inu(SHIB)$0.0000060.39%
  • crypto-com-chainCronos(CRO)$0.066324-1.00%
  • BitwayBitway(BTW)$1.2221.77%
  • Global DollarGlobal Dollar(USDG)$1.000.00%
  • tether-goldTether Gold(XAUT)$4,226.10-1.22%
  • paypal-usdPayPal USD(PYUSD)$1.000.00%
  • EthenaEthena(ENA)$0.2723071.39%
  • OndoOndo(ONDO)$0.564.97%
  • MemeCoreMemeCore(M)$1.17-4.79%
  • okbOKB(OKB)$120.75-0.05%
  • Ripple USDRipple USD(RLUSD)$1.000.01%
  • Pump.funPump.fun(PUMP)$0.00515217.45%
  • Circle USYCCircle USYC(USYC)$1.140.00%
  • aaveAave(AAVE)$153.36-0.87%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.150.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

YOU MAY ALSO LIKE

Which Is Better To Use?

Bill Gates Says It’s ‘Completely Irresponsible’ For AI To Not Have Safeguards

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

ShareTweetSendSharePin

Related Posts

Which Is Better To Use?
AI & Technology

Which Is Better To Use?

September 28, 2026
Bill Gates Says It’s ‘Completely Irresponsible’ For AI To Not Have Safeguards
AI & Technology

Bill Gates Says It’s ‘Completely Irresponsible’ For AI To Not Have Safeguards

September 27, 2026
Should You Ditch Your Tablet For A Foldable Phone?
AI & Technology

Should You Ditch Your Tablet For A Foldable Phone?

September 27, 2026
Why The iPhone Duo Could Be Beneficial For Samsung’s Galaxy Z Fold 8
AI & Technology

Why The iPhone Duo Could Be Beneficial For Samsung’s Galaxy Z Fold 8

September 27, 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
ANY Screen AI can DO THIS!

ANY Screen AI can DO THIS!

September 25, 2026
Paramount reaches settlement with California’s Rob Bonta to clear Warner Bros. merger

Paramount reaches settlement with California’s Rob Bonta to clear Warner Bros. merger

September 21, 2026
Police use cheese and bucket to rescue puppy from drain

Police use cheese and bucket to rescue puppy from drain

September 21, 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!