public class Formula
extends java.lang.Object
implements java.io.Serializable
| Constructor and Description |
|---|
Formula(HyperTerm[] predictors)
Constructor.
|
Formula(java.lang.String response)
Constructor.
|
Formula(java.lang.String response,
HyperTerm[] predictors)
Constructor.
|
Formula(Term response)
Constructor.
|
Formula(Term response,
HyperTerm[] predictors)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
DataFrame |
apply(DataFrame df)
Returns a data frame of predictors and response variable
|
Tuple |
apply(Tuple t)
Apply the formula on a tuple to generate the model data.
|
StructType |
bind(StructType inputSchema)
Binds the formula to a schema and returns the output schema of formula.
|
static Formula |
lhs(java.lang.String lhs)
Factory method.
|
static Formula |
lhs(Term lhs)
Factory method.
|
smile.math.matrix.DenseMatrix |
matrix(DataFrame df)
Creates a design matrix of predictors without bias column.
|
smile.math.matrix.DenseMatrix |
matrix(DataFrame df,
boolean bias)
Creates a design matrix of predictors.
|
static Formula |
of(java.lang.String response,
HyperTerm... predictors)
Factory method.
|
static Formula |
of(java.lang.String response,
java.lang.String... predictors)
Factory method.
|
static Formula |
of(Term response,
HyperTerm... predictors)
Factory method.
|
Formula |
predictors()
Returns a formula with only predictors.
|
java.util.Optional<Term> |
response()
Returns the response term.
|
static Formula |
rhs(HyperTerm... predictors)
Factory method.
|
static Formula |
rhs(java.lang.String... predictors)
Factory method.
|
StructType |
schema()
Returns the schema of output data frame.
|
java.lang.String |
toString() |
DataFrame |
x(DataFrame df)
Returns a data frame of predictors.
|
Tuple |
x(Tuple t)
Apply the formula on a tuple to generate the predictors data.
|
double[] |
xarray(Tuple t)
Returns the real values of predictors.
|
StructType |
xschema()
Returns the schema of design matrix.
|
BaseVector |
y(DataFrame df)
Returns the response vector.
|
double |
y(Tuple t)
Returns the real-valued response value.
|
int |
yint(Tuple t)
Returns the integer-valued response value.
|
public Formula(java.lang.String response)
response - the response formula, i.e. dependent variable.public Formula(Term response)
response - the response formula, i.e. dependent variable.public Formula(HyperTerm[] predictors)
predictors - the right-hand side of formula, i.e. independent/predictor variables.public Formula(java.lang.String response,
HyperTerm[] predictors)
response - the left-hand side of formula, i.e. dependent variable.predictors - the right-hand side of formula, i.e. independent/predictor variables.public Formula predictors()
public java.util.Optional<Term> response()
public java.lang.String toString()
toString in class java.lang.Objectpublic static Formula lhs(java.lang.String lhs)
lhs - the left-hand side of formula, i.e. dependent variable.public static Formula lhs(Term lhs)
lhs - the left-hand side of formula, i.e. dependent variable.public static Formula rhs(java.lang.String... predictors)
predictors - the right-hand side of formula, i.e. independent/predictor variables.public static Formula rhs(HyperTerm... predictors)
predictors - the right-hand side of formula, i.e. independent/predictor variables.public static Formula of(java.lang.String response, java.lang.String... predictors)
response - the left-hand side of formula, i.e. dependent variable.predictors - the right-hand side of formula, i.e. independent/predictor variables.public static Formula of(java.lang.String response, HyperTerm... predictors)
response - the left-hand side of formula, i.e. dependent variable.predictors - the right-hand side of formula, i.e. independent/predictor variables.public static Formula of(Term response, HyperTerm... predictors)
response - the left-hand side of formula, i.e. dependent variable.predictors - the right-hand side of formula, i.e. independent/predictor variables.public StructType schema()
public StructType xschema()
public StructType bind(StructType inputSchema)
public double[] xarray(Tuple t)
public DataFrame apply(DataFrame df)
df - The input DataFrame.public DataFrame x(DataFrame df)
df - The input DataFrame.public smile.math.matrix.DenseMatrix matrix(DataFrame df)
df - The input DataFrame.public smile.math.matrix.DenseMatrix matrix(DataFrame df, boolean bias)
df - The input DataFrame.bias - If true, the design matrix includes an all-one column for intercept.public BaseVector y(DataFrame df)
df - The input DataFrame.public double y(Tuple t)
public int yint(Tuple t)