Package org.pepstock.charba.client.ml
Class ExponentialRegression
- java.lang.Object
-
- org.pepstock.charba.client.ml.ExponentialRegression
-
- All Implemented Interfaces:
IsRegression
public final class ExponentialRegression extends Object
Exponential regression is a non-linear regression technique that looks like this:
y = A * eB * x
- Author:
- Andrea "Stock" Stocchero
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_FORMULA_PRECISION
Default precision to get the formula, 2.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getA()
Returns the A coefficient.double
getB()
Returns the B coefficient.List<Double>
getCoefficients()
Returns all calculated coefficients as a list.RegressionDescriptor
getDescriptor()
Returns the regression descriptor.RegressionType
getType()
Returns the regression type.boolean
isConsistent()
Returnstrue
if the regression is consistent and usable.double
predict(double x)
Returns the Y value, calculated by the regression formula at specific X value.List<Double>
predict(double... xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.double
predict(Date x)
Returns the Y value, calculated by the regression formula at specific X value.List<Double>
predict(List<Double> xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.double
predict(DataPoint dataPoint)
Returns the Y value, calculated by the regression formula at specific X value.double
predict(TimeSeriesItem item)
Returns the Y value, calculated by the regression formula at specific X value.List<Double>
predictByDataPoints(List<DataPoint> dataPoints)
Returns a list of Y values, calculated by the regression formula for specific X values.List<Double>
predictByDataPoints(DataPoint... dataPoints)
Returns a list of Y values, calculated by the regression formula for specific X values.List<Double>
predictByDates(Date... xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.List<Double>
predictByDates(List<Date> xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.List<Double>
predictByTimeSeriesItems(List<TimeSeriesItem> items)
Returns a list of Y values, calculated by the regression formula for specific X values.List<Double>
predictByTimeSeriesItems(TimeSeriesItem... items)
Returns a list of Y values, calculated by the regression formula for specific X values.RegressionScore
score(List<Double> y)
Evaluates the regression formula if the model fits enough.
X values are creating starting from 0 with increment of 1.RegressionScore
score(List<Double> y, double starting)
Evaluates the regression formula if the model fits enough.
X values are creating starting from passed argument with increment of 1.RegressionScore
score(List<Double> y, double starting, double increment)
Evaluates the regression formula if the model fits enough.
X values are creating starting from passed argument with increment of passed argument.RegressionScore
score(List<Double> x, List<Double> y)
Evaluates the regression formula if the model fits enough.RegressionScore
scoreByDataPoints(List<DataPoint> dataPoints)
Evaluates the regression formula if the model fits enough.RegressionScore
scoreByDate(List<Date> x, List<Double> y)
Evaluates the regression formula if the model fits enough.RegressionScore
scoreByTimeSeriesItems(List<TimeSeriesItem> items)
Evaluates the regression formula if the model fits enough.String
toFormula()
Returns the formula of the regression.String
toFormula(int precision)
Returns the formula of the regression, using the requested precision.String
toLaTeX()
Returns the formula of the regression.String
toLaTeX(int precision)
Returns the formula of the regression, using the requested precision.
-
-
-
Field Detail
-
DEFAULT_FORMULA_PRECISION
public static final int DEFAULT_FORMULA_PRECISION
Default precision to get the formula, 2.- See Also:
- Constant Field Values
-
-
Method Detail
-
getA
public double getA()
Returns the A coefficient.- Returns:
- the A coefficient
-
getB
public double getB()
Returns the B coefficient.- Returns:
- the B coefficient
-
getCoefficients
public List<Double> getCoefficients()
Description copied from interface:IsRegression
Returns all calculated coefficients as a list.- Returns:
- all calculated coefficients as a list
-
getType
public final RegressionType getType()
Returns the regression type.- Specified by:
getType
in interfaceIsRegression
- Returns:
- the regression type
-
getDescriptor
public final RegressionDescriptor getDescriptor()
Returns the regression descriptor.- Specified by:
getDescriptor
in interfaceIsRegression
- Returns:
- the regression descriptor
-
isConsistent
public final boolean isConsistent()
Description copied from interface:IsRegression
Returnstrue
if the regression is consistent and usable.- Specified by:
isConsistent
in interfaceIsRegression
- Returns:
true
if the regression is consistent and usable
-
predict
public final double predict(double x)
Description copied from interface:IsRegression
Returns the Y value, calculated by the regression formula at specific X value.- Specified by:
predict
in interfaceIsRegression
- Parameters:
x
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
public final double predict(Date x)
Description copied from interface:IsRegression
Returns the Y value, calculated by the regression formula at specific X value.- Specified by:
predict
in interfaceIsRegression
- Parameters:
x
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
public final double predict(DataPoint dataPoint)
Description copied from interface:IsRegression
Returns the Y value, calculated by the regression formula at specific X value.- Specified by:
predict
in interfaceIsRegression
- Parameters:
dataPoint
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
public final double predict(TimeSeriesItem item)
Description copied from interface:IsRegression
Returns the Y value, calculated by the regression formula at specific X value.- Specified by:
predict
in interfaceIsRegression
- Parameters:
item
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
public final List<Double> predict(double... xValues)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predict
in interfaceIsRegression
- Parameters:
xValues
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predict
public final List<Double> predict(List<Double> xValues)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predict
in interfaceIsRegression
- Parameters:
xValues
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predictByDates
public final List<Double> predictByDates(Date... xValues)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predictByDates
in interfaceIsRegression
- Parameters:
xValues
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predictByDates
public final List<Double> predictByDates(List<Date> xValues)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predictByDates
in interfaceIsRegression
- Parameters:
xValues
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predictByDataPoints
public final List<Double> predictByDataPoints(DataPoint... dataPoints)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predictByDataPoints
in interfaceIsRegression
- Parameters:
dataPoints
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predictByDataPoints
public final List<Double> predictByDataPoints(List<DataPoint> dataPoints)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predictByDataPoints
in interfaceIsRegression
- Parameters:
dataPoints
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predictByTimeSeriesItems
public final List<Double> predictByTimeSeriesItems(TimeSeriesItem... items)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predictByTimeSeriesItems
in interfaceIsRegression
- Parameters:
items
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
predictByTimeSeriesItems
public final List<Double> predictByTimeSeriesItems(List<TimeSeriesItem> items)
Description copied from interface:IsRegression
Returns a list of Y values, calculated by the regression formula for specific X values.- Specified by:
predictByTimeSeriesItems
in interfaceIsRegression
- Parameters:
items
- values to use to get the predicted values- Returns:
- a list of Y values, calculated by the regression formula for specific X values
-
score
public final RegressionScore score(List<Double> y)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.
X values are creating starting from 0 with increment of 1.- Specified by:
score
in interfaceIsRegression
- Parameters:
y
- Y values to use for evaluation- Returns:
- the score of the regression
-
score
public final RegressionScore score(List<Double> y, double starting)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.
X values are creating starting from passed argument with increment of 1.- Specified by:
score
in interfaceIsRegression
- Parameters:
y
- Y values to use for evaluationstarting
- starting value to create X values- Returns:
- the score of the regression
-
score
public final RegressionScore score(List<Double> y, double starting, double increment)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.
X values are creating starting from passed argument with increment of passed argument.- Specified by:
score
in interfaceIsRegression
- Parameters:
y
- Y values to use for evaluationstarting
- starting value to create X valuesincrement
- increment to apply to the starting value- Returns:
- the score of the regression
-
score
public final RegressionScore score(List<Double> x, List<Double> y)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.- Specified by:
score
in interfaceIsRegression
- Parameters:
x
- X values to use for evaluationy
- Y values to use for evaluation- Returns:
- the score of the regression
-
scoreByDate
public final RegressionScore scoreByDate(List<Date> x, List<Double> y)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.- Specified by:
scoreByDate
in interfaceIsRegression
- Parameters:
x
- X values to use for evaluationy
- Y values to use for evaluation- Returns:
- the score of the regression
-
scoreByDataPoints
public final RegressionScore scoreByDataPoints(List<DataPoint> dataPoints)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.- Specified by:
scoreByDataPoints
in interfaceIsRegression
- Parameters:
dataPoints
- X and Y values to use for evaluation- Returns:
- the score of the regression
-
scoreByTimeSeriesItems
public final RegressionScore scoreByTimeSeriesItems(List<TimeSeriesItem> items)
Description copied from interface:IsRegression
Evaluates the regression formula if the model fits enough.- Specified by:
scoreByTimeSeriesItems
in interfaceIsRegression
- Parameters:
items
- X and Y values to use for evaluation- Returns:
- the score of the regression
-
toFormula
public final String toFormula()
Description copied from interface:IsRegression
Returns the formula of the regression.- Specified by:
toFormula
in interfaceIsRegression
- Returns:
- the formula of the regression
-
toFormula
public final String toFormula(int precision)
Description copied from interface:IsRegression
Returns the formula of the regression, using the requested precision.- Specified by:
toFormula
in interfaceIsRegression
- Parameters:
precision
- precision to apply to the numbers of the formula- Returns:
- the formula of the regression
-
toLaTeX
public final String toLaTeX()
Description copied from interface:IsRegression
Returns the formula of the regression.- Specified by:
toLaTeX
in interfaceIsRegression
- Returns:
- the formula of the regression
-
toLaTeX
public final String toLaTeX(int precision)
Description copied from interface:IsRegression
Returns the formula of the regression, using the requested precision.- Specified by:
toLaTeX
in interfaceIsRegression
- Parameters:
precision
- precision to apply to the numbers of the formula- Returns:
- the formula of the regression
-
-