public final class InputPeriod
extends java.lang.Object
implements java.io.Serializable
InputPeriod
items together forms the InputData
required for every RegressionRequest
.
To create a simple InputPeriod
just use the
InputPeriod(DayRange, double)
constructor. If, then, you also wish to
add extra-predictor figures, use the withExtraPredictor(java.lang.String, double)
method.
See www.degreedays.net/api/regression for more information and code samples.
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
Constructor and Description |
---|
InputPeriod(DayRange dayRange,
double usage)
Constructs an
InputPeriod covering the specified
DayRange and with the specified energy usage . |
Modifier and Type | Method and Description |
---|---|
DayRange |
dayRange()
Returns the non-null period of time covered by this
InputPeriod . |
boolean |
equals(java.lang.Object o)
|
java.util.Set<java.lang.String> |
extraPredictorKeys()
Returns the non-null, possibly-empty, immutable set of extra-predictor
keys that this
InputPeriod has extra-predictor figures for. |
double |
getExtraPredictor(java.lang.String key)
Returns the
double value of the extra predictor with the
specified string key . |
int |
hashCode()
Overridden to ensure consistency with
equals . |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
|
double |
usage()
Returns the energy usage over this
InputPeriod . |
InputPeriod |
withExtraPredictor(java.lang.String key,
double value)
Returns a new
InputPeriod based on this but
also including an extra predictor with the specified key and
value . |
public InputPeriod(DayRange dayRange, double usage)
InputPeriod
covering the specified
DayRange
and with the specified energy usage
.dayRange
- the non-null period of time covered.usage
- the energy usage over the specified dayRange
.java.lang.NullPointerException
- if
dayRange
is null
.java.lang.IllegalArgumentException
- if usage
is
NaN
or infinity.public DayRange dayRange()
InputPeriod
.public double usage()
InputPeriod
.public java.util.Set<java.lang.String> extraPredictorKeys()
InputPeriod
has extra-predictor figures for.public double getExtraPredictor(java.lang.String key)
double
value of the extra predictor with the
specified string key
.key
- a non-null, non-empty string key.java.lang.NullPointerException
- if key
is null
.java.lang.IllegalArgumentException
- if key
isn't one of the
extra-predictor keys stored in this object.extraPredictorKeys()
,
withExtraPredictor(java.lang.String, double)
public InputPeriod withExtraPredictor(java.lang.String key, double value)
InputPeriod
based on this
but
also including an extra predictor with the specified key
and
value
.
Every InputPeriod
in a set of InputData
must have
values for the same extra-predictor keys. So, for example, if you include
an "occupancy"
extra-predictor figure in one
InputPeriod
in your InputData
, you must include
an "occupancy"
figure in all of them.
There's some sample code showing how to use this method in the regression API docs on our website, and also there's some additional practical information on specifying and using extra predictors in the docs for our website regression tool (which itself uses the API internally).
key
- the extra-predictor key used to identify this extra predictor.
Cannot be null
, must match the regular expression
[-_.a-zA-Z0-9]{1,60}
, and cannot be
"baseload"
, "heatingDegreeDays"
, or
"coolingDegreeDays"
.value
- the value of the extra predictor over the time period
covered by this InputPeriod
's dayRange()
.java.lang.NullPointerException
- if key
is null
.java.lang.IllegalArgumentException
- if key
does not match the
specification detailed above, or if value
is
NaN
or infinite.java.lang.IllegalStateException
- if this
InputPeriod
already has 2 extra predictors (the
maximum allowed).public boolean equals(java.lang.Object o)
true
if o
is an
InputPeriod
with the same dayRange
and
usage
as this
, and with the same extra-predictor
keys and values (the order of the keys
is not important for 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.