public final class RegressionSpec
extends java.lang.Object
implements java.io.Serializable
To create a RegressionSpec
, start with a baseload-only spec from
baseload()
(since every regression needs a baseload component), then
build upon it using whichever of the withXXX
methods you need.
For example:
RegressionSpec spec = RegressionSpec.baseload()
.withHeating(Temperature.celsius(15.5))
.withCooling(Temperature.celsius(21))
.withExtraPredictorKeys("occupancy", "production");
See www.degreedays.net/api/regression#requested for more information and code samples.
RegressionTestPlan.Builder.setRequestedRegressionSpecs(RegressionSpec...)
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
Modifier and Type | Method and Description |
---|---|
static RegressionSpec |
baseload()
Returns a specification for a baseload-only regression
(e.g.
E = b*days ) which can be built upon as
per the example code. |
boolean |
equals(java.lang.Object o)
Returns
true if o is a
RegressionSpec with the same configuration as
this . |
java.util.Set<java.lang.String> |
extraPredictorKeys()
Returns the non-null, possibly-empty, immutable set of the keys of the
extra predictors to be included in the specified regression.
|
Temperature |
getCoolingBaseTemperature()
Returns the non-null base temperature to be used for the cooling degree
days in the specified regression, or throws an
IllegalStateException if it was never set (call
hasCooling() before calling this). |
Temperature |
getHeatingBaseTemperature()
Returns the non-null base temperature to be used for the heating degree
days in the specified regression, or throws an
IllegalStateException if it was never set (call
hasHeating() before calling this). |
boolean |
hasCooling()
Returns
true if the regression is specified to include
cooling degree days; false otherwise. |
int |
hashCode()
Overridden to ensure consistency with
equals . |
boolean |
hasHeating()
Returns
true if the regression is specified to include
heating degree days; false otherwise. |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
|
RegressionSpec |
withCooling(Temperature coolingBaseTemperature)
Returns a new
RegressionSpec based on this but
also specifying that cooling degree days with the specified base
temperature are to be included. |
RegressionSpec |
withExtraPredictorKeys(java.lang.Iterable<java.lang.String> keys)
Returns a new
RegressionSpec based on this but
also specifying that extra predictors with the specified
keys are to be included. |
RegressionSpec |
withExtraPredictorKeys(java.lang.String... keys)
Returns a new
RegressionSpec based on this but
also specifying that extra predictors with the specified
keys are to be included. |
RegressionSpec |
withHeating(Temperature heatingBaseTemperature)
Returns a new
RegressionSpec based on this but
also specifying that heating degree days with the specified base
temperature are to be included. |
public static RegressionSpec baseload()
E = b*days
) which can be built upon as
per the example code.public RegressionSpec withHeating(Temperature heatingBaseTemperature)
RegressionSpec
based on this
but
also specifying that heating degree days with the specified base
temperature are to be included.heatingBaseTemperature
- the base temperature of the heating degree
days to be included in the specified regression. Cannot be
null
.java.lang.NullPointerException
- if heatingBaseTemperature
is
null
.java.lang.IllegalArgumentException
- if this
already has a
cooling base temperature, but heatingBaseTemperature
does not have the same temperature
unit.public RegressionSpec withCooling(Temperature coolingBaseTemperature)
RegressionSpec
based on this
but
also specifying that cooling degree days with the specified base
temperature are to be included.coolingBaseTemperature
- the base temperature of the cooling degree
days to be included in the specified regression. Cannot be
null
.java.lang.NullPointerException
- if coolingBaseTemperature
is
null
.java.lang.IllegalArgumentException
- if this
already has a
heating base temperature, but coolingBaseTemperature
does not have the same temperature
unit.public RegressionSpec withExtraPredictorKeys(java.lang.String... keys)
RegressionSpec
based on this
but
also specifying that extra predictors with the specified
keys
are to be included.keys
- the extra-predictor keys that identify the extra predictors
to be included in the regression. There can be a maximum of 2
keys. Each key must match the regular expression
[-_.a-zA-Z0-9]{1,60}
, with "baseload"
,
"heatingDegreeDays"
, and
"coolingDegreeDays"
specifically disallowed.java.lang.NullPointerException
- if keys
is null
or
contains null
.java.lang.IllegalArgumentException
- if there are more than 2 keys, or if any
of the keys do not match the specification detailed above.withExtraPredictorKeys(Iterable)
public RegressionSpec withExtraPredictorKeys(java.lang.Iterable<java.lang.String> keys)
RegressionSpec
based on this
but
also specifying that extra predictors with the specified
keys
are to be included.keys
- the extra-predictor keys that identify the extra predictors
to be included in the regression. There can be a maximum of 2
keys. Each key must match the regular expression
[-_.a-zA-Z0-9]{1,60}
, with "baseload"
,
"heatingDegreeDays"
, and
"coolingDegreeDays"
specifically disallowed.java.lang.NullPointerException
- if keys
is null
or
contains null
.java.lang.IllegalArgumentException
- if there are more than 2 keys, or if any
of the keys do not match the specification detailed above.withExtraPredictorKeys(String...)
public boolean hasHeating()
true
if the regression is specified to include
heating degree days; false
otherwise.
If this returns true
, it is safe to call
getHeatingBaseTemperature()
.
public Temperature getHeatingBaseTemperature()
IllegalStateException
if it was never set (call
hasHeating()
before calling this).java.lang.IllegalStateException
- if this RegressionSpec
does
not hold a heating base temperature.withHeating(net.degreedays.api.data.Temperature)
public boolean hasCooling()
true
if the regression is specified to include
cooling degree days; false
otherwise.
If this returns true
, it is safe to call
getCoolingBaseTemperature()
.
public Temperature getCoolingBaseTemperature()
IllegalStateException
if it was never set (call
hasCooling()
before calling this).java.lang.IllegalStateException
- if this RegressionSpec
does
not hold a cooling base temperature.withCooling(net.degreedays.api.data.Temperature)
public java.util.Set<java.lang.String> extraPredictorKeys()
public boolean equals(java.lang.Object o)
true
if o
is a
RegressionSpec
with the same configuration as
this
.equals
in class java.lang.Object
public int hashCode()
equals
.hashCode
in class java.lang.Object
public java.lang.String toString()
The exact details of the representation are unspecified and subject to change.
toString
in class java.lang.Object
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.