# Import the required ArcGIS API for Python modules
import arcgis
from arcgis.gis import GIS
# Connect to your ArcGIS Enterprise portal and confirm that GeoAnalytics is supported
portal = GIS("https://myportal.domain.com/portal", "gis_publisher", "my_password")
if not portal.geoanalytics.is_supported():
print("Quitting, GeoAnalytics is not supported")
exit(1)
# Search for and list the big data file shares in your portal
search_result = portal.content.search("", "Big Data File Share")
# Look through the search results for a big data file share with the matching name
bdfs_search = next(x for x in search_result if x.title == "bigDataFileShares_SalesData")
# Look through the big data file share for 2018 sales data to model
model_layer = next(x for x in bdfs_search.layers if x.properties.name == "2018_sales")
# Find the dataset you want to predict
predict_layer_search = portal.content.search("Sales_2025", "Feature Layer")
predict_layer = predict_layer_search[0].layers[0]
# Run the Generalized Linear Regression tool
glr_result = arcgis.geoanalytics.analyze_patterns.glr(input_layer = model_layer,
features_to_predict = predict_layer,
var_explanatory = "salestotal, store_count, advertisingcost",
var_dependent = "chicago_crimes_enriched",
regression_family = "Count",
exp_var_matching = [{"predictionLayerField":"store_count",
"trainingLayerField": "num_of_stores"}],
output_name = "predicted_customers")
# Visualize the results if you are running Python in a Jupyter Notebook
processed_map = portal.map()
processed_map.add_layer(glr_result)
processed_map