Class HoltWintersModel

java.lang.Object
org.elasticsearch.search.aggregations.pipeline.MovAvgModel
org.elasticsearch.search.aggregations.pipeline.HoltWintersModel
All Implemented Interfaces:
NamedWriteable, Writeable, ToXContent, ToXContentFragment

public class HoltWintersModel extends MovAvgModel
Calculate a triple exponential weighted moving average
  • Field Details

  • Constructor Details

    • HoltWintersModel

      public HoltWintersModel()
    • HoltWintersModel

      public HoltWintersModel(double alpha, double beta, double gamma, int period, HoltWintersModel.SeasonalityType seasonalityType, boolean pad)
    • HoltWintersModel

      public HoltWintersModel(StreamInput in) throws IOException
      Read from a stream.
      Throws:
      IOException
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from class: MovAvgModel
      Write the model to the output stream
      Specified by:
      writeTo in interface Writeable
      Specified by:
      writeTo in class MovAvgModel
      Parameters:
      out - Output stream
      Throws:
      IOException
    • getWriteableName

      public String getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object
    • minimizeByDefault

      public boolean minimizeByDefault()
      Description copied from class: MovAvgModel
      Should this model be fit to the data via a cost minimizing algorithm by default?
      Overrides:
      minimizeByDefault in class MovAvgModel
    • canBeMinimized

      public boolean canBeMinimized()
      Description copied from class: MovAvgModel
      Returns if the model can be cost minimized. Not all models have parameters which can be tuned / optimized.
      Specified by:
      canBeMinimized in class MovAvgModel
    • neighboringModel

      public MovAvgModel neighboringModel()
      Description copied from class: MovAvgModel
      Generates a "neighboring" model, where one of the tunable parameters has been randomly mutated within the allowed range. Used for minimization
      Specified by:
      neighboringModel in class MovAvgModel
    • clone

      public MovAvgModel clone()
      Description copied from class: MovAvgModel
      Clone the model, returning an exact copy
      Specified by:
      clone in class MovAvgModel
    • hasValue

      public boolean hasValue(int valuesAvailable)
      Description copied from class: MovAvgModel
      Checks to see this model can produce a new value, without actually running the algo. This can be used for models that have certain preconditions that need to be met in order to short-circuit execution
      Overrides:
      hasValue in class MovAvgModel
      Parameters:
      valuesAvailable - Number of values in the current window of values
      Returns:
      Returns `true` if calling next() will produce a value, `false` otherwise
    • doPredict

      protected double[] doPredict(Collection<Double> values, int numPredictions)
      Predicts the next `n` values in the series, using the smoothing model to generate new values. Unlike the other moving averages, HoltWinters has forecasting/prediction built into the algorithm. Prediction is more than simply adding the next prediction to the window and repeating. HoltWinters will extrapolate into the future by applying the trend and seasonal information to the smoothed data.
      Specified by:
      doPredict in class MovAvgModel
      Parameters:
      values - Collection of numerics to movingAvg, usually windowed
      numPredictions - Number of newly generated predictions to return
      Returns:
      Returns an array of doubles, since most smoothing methods operate on floating points
    • next

      public double next(Collection<Double> values)
      Description copied from class: MovAvgModel
      Returns the next value in the series, according to the underlying smoothing model
      Specified by:
      next in class MovAvgModel
      Parameters:
      values - Collection of numerics to movingAvg, usually windowed
      Returns:
      Returns a double, since most smoothing methods operate on floating points
    • next

      public double[] next(Collection<Double> values, int numForecasts)
      Calculate a doubly exponential weighted moving average
      Parameters:
      values - Collection of values to calculate avg for
      numForecasts - number of forecasts into the future to return
      Returns:
      Returns a Double containing the moving avg for the window
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Throws:
      IOException
    • validate

      protected void validate(long window, String aggregationName)
      If the model is a HoltWinters, we need to ensure the window and period are compatible. This is verified in the XContent parsing, but transport clients need these checks since they skirt XContent parsing
      Overrides:
      validate in class MovAvgModel
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class MovAvgModel
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in class MovAvgModel