public final class RegressionApi extends java.lang.Object
Instead of creating a
RegressionApi instance directly, you would
typically create a
DegreeDaysApi object and get a
RegressionApi from that with
DegreeDaysApi.regressionApi(). Although the only state of a
RegressionApi object is the
RequestProcessor passed into
its constructor, so, if you have a
RequestProcessor, there's no
reason not to create a
RegressionApi object directly if doing it
that way makes sense for your app.
Please see the Java code samples in the regression API docs on our website.
This class is designed to be safe for use from multiple concurrent threads. However, if you create a customized instance of this class (using a
RequestProcessor that you have written or customized), then the thread-safety of its operation will depend on the thread-safety of that
|Constructor and Description|
public RegressionApi(RequestProcessor requestProcessor)
RegressionApiobject that uses the specified
requestProcessor- the non-null
RequestProcessorthat the new
RegressionApiobject should use internally for its processing.
public RegressionResponse runRegressions(RegressionRequest request)
RegressionRequestto the API servers so it can run regressions against your
InputDataand return a non-null
RegressionResponsecontaining the regressions that were statistically best and/or any that you specifically requested.
The API's processing will typically require it to generate degree days to
InputData you provide in your request, so it can use
those degree days in the regressions it tests. To do this it will use the
Location specified in your request.
If you specify a
then the API will use data from that station. But, if you specify a
GeographicLocation, the API will choose
which station(s) to use automatically. The choice will depend on the
dates of your
InputData as well as the location you specify. Some
stations have more data than others, and the quality of a station's data
can vary over time. The API will choose the station(s) that can best
match the data you provide in your request.
If you specify an inactive weather station (more on these
here), or a
GeographicLocation for which no active
station can be found with enough data to run regressions against your
InputData, you will get a
LocationException instead of a
Regressions not covering all of your input data:
If the location you specify in your request does not have sufficient
weather data for the API to run regressions against your full input data,
it may still be able to run regressions against part of it. You can check
Regression.sampleSize() and the
Regression.sampleSpan() of any
Regression in the
response (comparing with
InputData.fullRange()) to see if this has happened.
It is unlikely to happen unless you are trying to run regressions against
very old energy data, or very recent energy data e.g. that includes a day
that finished in the last hour or two. If you want to be sure to prevent
it from happening, you could make a
LocationInfoRequest first, specifying
data with a
InputData, with a
minimum DayRange that also specifies that same
DayRange. If you get a successful response
back you will have a weather station ID that you know you can use in your
regression request. But you will have used only 1 request unit to find
that out (versus however many it might take to run a load of regressions
that might only cover part of your data).
InputData(energy data) you want regressions to be run against, the
Locationfor which degree days should be generated to use in those regressions, and the
RegressionTestPlandefining what regressions the API should test and potentially return. Cannot be
RegressionResponsecontaining the regressions that the API found to give the best statistical fit with your
LocationException- if the request fails because of problems relating to the specified
ServiceException- if the request fails because of a problem with the API service (sorry!).
RateLimitException- if you hit the
RateLimitfor your account's plan, and need to wait a little while before it's reset.
InvalidRequestException- if the request that is sent to the API servers is invalid (e.g. if it is authenticated with invalid API access keys or because regression is not available on the current API account plan).
TransportException- if there's a problem sending the request to the API servers, or a problem getting the API's response back.
DegreeDaysApiException- the superclass of all the exceptions listed above.
www.degreedays.net/api/regression for more information and code samples.
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.