Demo entry 6783338

test

   

Submitted by m on Feb 08, 2019 at 14:13
Language: Scala. Code size: 1.2 kB.

// forecaster instantiation
  val forecaster = new XGBForecaster(rev_ts.filter($"date" < stay_date), stay_date, "custom_features")
   
  // add XLR signal
  forecaster.addExogenousFeature(df.select("date", "total_margin_pct").filter($"date" < stay_date), "date")
  forecaster.addExogenousFeature(holidaySignal.filter($"date" < stay_date), "date")
   
  // forecaster training
  forecaster.train(Some(Parameters(maxDepth = Array(5, 6, 7, 8),
                                   eta = Array(0.4, 0.5, 0.6, 0.7),
                                   numRound = Array(150, 200, 250),
                                   colsampleBytree = Array(0.5))))
   
  forecaster.save(s"${hotelid}_${stay_date}_trained")
   
  // collect exogenous variables
  val exo_features = df.select("date", "total_margin_pct")
                     .join(holidaySignal, Seq("date"))
   
  // forecast
  forecaster.extendToHorizon(horizon, exo_features)
 
  // evaluate
  val results = compare(forecaster._ts, rev_ts, stay_date, horizon)
  toS3(s"${hotelid}_${stay_date}_results", results, path="s3://sortteam-devel/myaghini/results/")
   
  // save the forecast model
  forecaster.save(s"${hotelid}_${stay_date}_forecast")

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).