Class HoltWintersModel
- java.lang.Object
-
- org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel
-
- org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltWintersModel
-
- All Implemented Interfaces:
NamedWriteable
,Writeable
,ToXContent
,ToXContentFragment
public class HoltWintersModel extends MovAvgModel
Calculate a triple exponential weighted moving average
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HoltWintersModel.HoltWintersModelBuilder
static class
HoltWintersModel.SeasonalityType
-
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel
MovAvgModel.AbstractModelParser
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_ALPHA
static double
DEFAULT_BETA
static double
DEFAULT_GAMMA
static boolean
DEFAULT_PAD
static int
DEFAULT_PERIOD
static HoltWintersModel.SeasonalityType
DEFAULT_SEASONALITY_TYPE
static java.lang.String
NAME
static MovAvgModel.AbstractModelParser
PARSER
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description HoltWintersModel()
HoltWintersModel(double alpha, double beta, double gamma, int period, HoltWintersModel.SeasonalityType seasonalityType, boolean pad)
HoltWintersModel(StreamInput in)
Read from a stream.
-
Method Summary
Modifier and Type Method Description boolean
canBeMinimized()
Returns if the model can be cost minimized.MovAvgModel
clone()
Clone the model, returning an exact copyprotected double[]
doPredict(java.util.Collection<java.lang.Double> values, int numPredictions)
Predicts the next `n` values in the series, using the smoothing model to generate new values.boolean
equals(java.lang.Object obj)
java.lang.String
getWriteableName()
Returns the name of the writeable objectint
hashCode()
boolean
hasValue(int valuesAvailable)
Checks to see this model can produce a new value, without actually running the algo.boolean
minimizeByDefault()
Should this model be fit to the data via a cost minimizing algorithm by default?MovAvgModel
neighboringModel()
Generates a "neighboring" model, where one of the tunable parameters has been randomly mutated within the allowed range.double
next(java.util.Collection<java.lang.Double> values)
Returns the next value in the series, according to the underlying smoothing modeldouble[]
next(java.util.Collection<java.lang.Double> values, int numForecasts)
Calculate a doubly exponential weighted moving averageXContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
writeTo(StreamOutput out)
Write the model to the output stream-
Methods inherited from class org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel
emptyPredictions, predict
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_ALPHA
public static final double DEFAULT_ALPHA
- See Also:
- Constant Field Values
-
DEFAULT_BETA
public static final double DEFAULT_BETA
- See Also:
- Constant Field Values
-
DEFAULT_GAMMA
public static final double DEFAULT_GAMMA
- See Also:
- Constant Field Values
-
DEFAULT_PERIOD
public static final int DEFAULT_PERIOD
- See Also:
- Constant Field Values
-
DEFAULT_SEASONALITY_TYPE
public static final HoltWintersModel.SeasonalityType DEFAULT_SEASONALITY_TYPE
-
DEFAULT_PAD
public static final boolean DEFAULT_PAD
- See Also:
- Constant Field Values
-
PARSER
public static final MovAvgModel.AbstractModelParser PARSER
-
-
Constructor Detail
-
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 java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from class:MovAvgModel
Write the model to the output stream- Specified by:
writeTo
in interfaceWriteable
- Specified by:
writeTo
in classMovAvgModel
- Parameters:
out
- Output stream- Throws:
java.io.IOException
-
getWriteableName
public java.lang.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 classMovAvgModel
-
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 classMovAvgModel
-
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 classMovAvgModel
-
clone
public MovAvgModel clone()
Description copied from class:MovAvgModel
Clone the model, returning an exact copy- Specified by:
clone
in classMovAvgModel
-
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 classMovAvgModel
- 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(java.util.Collection<java.lang.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 classMovAvgModel
- Parameters:
values
- Collection of numerics to movingAvg, usually windowednumPredictions
- 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(java.util.Collection<java.lang.Double> values)
Description copied from class:MovAvgModel
Returns the next value in the series, according to the underlying smoothing model- Specified by:
next
in classMovAvgModel
- 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(java.util.Collection<java.lang.Double> values, int numForecasts)
Calculate a doubly exponential weighted moving average- Parameters:
values
- Collection of values to calculate avg fornumForecasts
- 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 java.io.IOException
- Throws:
java.io.IOException
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classMovAvgModel
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in classMovAvgModel
-
-