ArcGIS REST API

Generalized Linear Regression

Generalized Linear Regression

This tool performs Generalized Linear Regression (GLR) to generate predictions or to model a dependent variable's relationship to a set of explanatory variables. This tool can be used to fit continuous (Gaussian and OLS), binary (logistic), and count (Poisson) models.

The following are examples of the types of questions you can answer using this tool:

  • What demographic characteristics contribute to high rates of public transportation usage?
  • Is there a positive relationship between vandalism and burglary?
  • Which variables effectively predict 911 call volume? Given future projections, what is the expected demand for emergency response resources?
  • What variables affect low birth rates?

Note:

Generalized Linear Regression was introduced in ArcGIS Enterprise 10.7.

Request URL

https://<analysis URL>/GeneralizedLinearRegression/submitJob

Request parameters

ParameterDescription

inputLayer

(Required)

The layer containing the dependent and independent variables.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST web example:

  • {"url" : "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

REST scripting example:

  • "pointLayer" : {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

featuresToPredict

(Optional)

A layer containing features representing locations where estimates should be computed. Each feature in this dataset should contain values for all the explanatory variables specified. The dependent variable for these features will be estimated using the model calibrated for the input layer data.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

dependentVariable

(Required)

The numeric field containing the observed values you want to model.

REST web example: Earnings

REST scripting example: "dependentVariable": "Arrest"

explanatoryVariables

(Required)

One or more fields representing independent explanatory variables in your regression model.

REST web example: Rate

REST scripting example: "explanatoryVariables": "Rating,Nights"

regressionFamily

(Required)

Specifies the type of data you're modeling.

regressionFamily is one of the following:

  • Continuous—The dependentVariable is continuous. The model used is Gaussian, and the tool performs ordinary least squares regression.
  • Binary—The dependentVariable represents presence or absence. Values must be 0 (absence) or 1 (presence), or mapped to 0 and 1 values using the parameter.
  • Count—The dependentVariable is discrete and represents events, such as crime counts, disease incidents, or traffic accidents. The model used is Poisson regression.

REST web example: Continuous

REST scripting example: "regressionFamily": "Binary"

generateCoefficientTable

(Optional)

Determines whether a table with coefficient values will be returned. By default, the coefficient table is not returned.

Values: true| false

REST web example: false

REST scripting example: "generateCoefficientTable": false

explanatoryVariableMatching

(Optional)

A list of the explanatoryVariables specified from the inputLayer and their corresponding fields from the featuresToPredict. By default, if an explanatoryVariable is not mapped, it will match to a field with the same name in the featuresToPredict. This parameter is only used if there is a featuresToPredict input. You do not need to use it if the names and types of the fields match between your two input datasets.

Syntax: [{"predictionLayerField":"<field name>", "trainingLayerField": "<field name>"},...]

predictionLayerField is the name of a field specified in the explanatoryVariables parameter.

trainingLayerField is the field that will match to the field in the explanatoryVariables parameter.

REST web example: [{"predictionLayerField":"CrimeType", "trainingLayerField": "TypeOfCrime"},{"predictionLayerField":"population", "trainingLayerField": "population"}]

REST scripting example: "variablePredict":[{"predictionLayerField":"isSunny", "trainingLayerField": "isSunny2010"}]

dependentMapping

(Optional)

A list representing the values used to map to 0 (absence) and 1 (presence) for binary regression.

Syntax: [{"value0":"<false value>"},{"value1":"<true value>"}]

value0 is the string that will be used to represent 0 (absence values).

value1 is the string that will be used to represent 1(presence values).

REST web example: [{"value0":"NoArrest"},{"value1":"Arrest"}]

REST scripting example: [{"value0":"Fail"},{"value1":"Pass"}]

outputName

(Required)

The task will create a feature service of the results. You define the name of the service.

REST web example: myOutput

REST scripting example: "outputName" : "myOutput"

context

(Optional)

The context parameter contains additional settings that affect task execution. For this task, there are four settings:

  • Extent (extent)—A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.
  • Processing spatial reference (processSR)—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR)—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore)—Results will be saved to the specified data store. The default is the spatiotemporal big data store.

Syntax:
{
"extent" : {extent},
"processSR" : {spatial reference},
"outSR" : {spatial reference},
"dataStore":{data store}
}

f

The response format. The default response format is html.

Values: html | json

Response

When you submit a request, the service assigns a unique job ID for the transaction.

Syntax:
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically check the status of the job and messages as described in Checking job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>

Access results

When the status of the job request is esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/output?token=<your token>&f=json

https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/outputPredicted?token=<your token>&f=json

https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/coefficientTable?token=<your token>&f=json

https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/processInfo?token=<your token>&f=json

ParameterDescription

output

The input features that are fit to the model. The type of feature (table, point, line, or polygon) depends on the input layers.

Request example:
{"url": 
"https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.

outputPredicted

The features predicted using the model. The type of feature (table, point, line, or polygon) depends on the input layers. This result is optional and is only returned when featureToPredict is provided as input.

Request example:
{"url": 
"https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/outputPredicted"}

coefficientTable

A table representing the coefficients from the model fit. This result is optional and is only returned when generateCoefficientTable is true.

Request example:
{"url": 
"https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>/results/coefficientTable"}

processInfo

The processInfo parameter contains strings that summarize the Forest-based Classification and Regression result. These strings are used for reporting by the Generalized Linear Regression in the map viewer. You can create your own custom reports for your application using these strings. There are four parts in the returned JSON as follows:

  • messageCode—The serial number for each unique message.
  • message—Text that may or may not contain parameters (in ${paramsName} format) that need to be replaced by values.
  • params—A dictionary of the keys and values to be inserted into the ${paramsName} parameter in the message.
  • style—The formatting of the report produced by the Generalized Linear Regression tool in the map viewer.
Example:
{
"messageCode" : "SS_84507",
"message" : ["Attribute", "Min", "Max", "SD", "Mean","Input"],
"params" : {},
"style" : "<table><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr>" ,,
}