Package org.pepstock.charba.client.ml
Interface IsRegression
-
- All Known Implementing Classes:
ExponentialRegression
,LinearRegression
,PolynomialRegression
,PowerRegression
,RobustPolynomialRegression
,TheilSenRegression
public interface IsRegression
Maps all common methods of a regression.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <T extends IsRegression>
TcheckAndGetIfValid(T regression)
Checks if regression passed as argument is notnull
and if consistent as well.
If not, throw aIllegalArgumentException
, otherwise it returns the regression.static void
checkIfValid(IsRegression regression)
Checks if regression passed as argument is notnull
and if consistent as well.
If not, throw aIllegalArgumentException
.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.
-
-
-
Method Detail
-
checkIfValid
static void checkIfValid(IsRegression regression)
Checks if regression passed as argument is notnull
and if consistent as well.
If not, throw aIllegalArgumentException
.- Parameters:
regression
- regression to be checked
-
checkAndGetIfValid
static <T extends IsRegression> T checkAndGetIfValid(T regression)
Checks if regression passed as argument is notnull
and if consistent as well.
If not, throw aIllegalArgumentException
, otherwise it returns the regression.- Type Parameters:
T
- type of regression- Parameters:
regression
- regression to be checked- Returns:
- the same regression passed as argument
-
getType
RegressionType getType()
Returns the regression type.- Returns:
- the regression type
-
getDescriptor
RegressionDescriptor getDescriptor()
Returns the regression descriptor.- Returns:
- the regression descriptor
-
getCoefficients
List<Double> getCoefficients()
Returns all calculated coefficients as a list.- Returns:
- all calculated coefficients as a list
-
isConsistent
boolean isConsistent()
Returnstrue
if the regression is consistent and usable.- Returns:
true
if the regression is consistent and usable
-
predict
double predict(double x)
Returns the Y value, calculated by the regression formula at specific X value.- Parameters:
x
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
double predict(Date x)
Returns the Y value, calculated by the regression formula at specific X value.- Parameters:
x
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
double predict(DataPoint dataPoint)
Returns the Y value, calculated by the regression formula at specific X value.- Parameters:
dataPoint
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
double predict(TimeSeriesItem item)
Returns the Y value, calculated by the regression formula at specific X value.- Parameters:
item
- value to use to get the predicted value- Returns:
- the Y value, calculated by the regression formula at specific X value
-
predict
List<Double> predict(double... xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predict(List<Double> xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predictByDates(Date... xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predictByDates(List<Date> xValues)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predictByDataPoints(DataPoint... dataPoints)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predictByDataPoints(List<DataPoint> dataPoints)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predictByTimeSeriesItems(TimeSeriesItem... items)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
List<Double> predictByTimeSeriesItems(List<TimeSeriesItem> items)
Returns a list of Y values, calculated by the regression formula for specific X values.- 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
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.- Parameters:
y
- Y values to use for evaluation- Returns:
- the score of the regression
-
score
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.- Parameters:
y
- Y values to use for evaluationstarting
- starting value to create X values- Returns:
- the score of the regression
-
score
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.- 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
RegressionScore score(List<Double> x, List<Double> y)
Evaluates the regression formula if the model fits enough.- Parameters:
x
- X values to use for evaluationy
- Y values to use for evaluation- Returns:
- the score of the regression
-
scoreByDate
RegressionScore scoreByDate(List<Date> x, List<Double> y)
Evaluates the regression formula if the model fits enough.- Parameters:
x
- X values to use for evaluationy
- Y values to use for evaluation- Returns:
- the score of the regression
-
scoreByDataPoints
RegressionScore scoreByDataPoints(List<DataPoint> dataPoints)
Evaluates the regression formula if the model fits enough.- Parameters:
dataPoints
- X and Y values to use for evaluation- Returns:
- the score of the regression
-
scoreByTimeSeriesItems
RegressionScore scoreByTimeSeriesItems(List<TimeSeriesItem> items)
Evaluates the regression formula if the model fits enough.- Parameters:
items
- X and Y values to use for evaluation- Returns:
- the score of the regression
-
toFormula
String toFormula()
Returns the formula of the regression.- Returns:
- the formula of the regression
-
toFormula
String toFormula(int precision)
Returns the formula of the regression, using the requested precision.- Parameters:
precision
- precision to apply to the numbers of the formula- Returns:
- the formula of the regression
-
toLaTeX
String toLaTeX()
Returns the formula of the regression.- Returns:
- the formula of the regression
-
toLaTeX
String toLaTeX(int precision)
Returns the formula of the regression, using the requested precision.- Parameters:
precision
- precision to apply to the numbers of the formula- Returns:
- the formula of the regression
-
-