Here is an dummy tool template that you can use to prototype your tool. This tool template assumes that each row of your training dataset corresponds to an address.
Note that this tool uses a dummy model. Please modify the inputs, outputs and model to fit your chosen hypothesis and training dataset.
Thanks to the following groups for making this work possible:
{address_table : Addresses ? Specify the addresses for which you would like to predict metrics}
# CrossCompute
ready_table_path = 'Ready Table with 490 rows.csv'
target_folder = '/tmp'
import pandas as pd
ready_table = pd.read_csv(ready_table_path)
ready_table = ready_table[[#'formatted_address',
'Longitude','Latitude','Total Tree Count within 0.5 Mile','Periodic Savings within 0.5 Mile']]
ready_table[:3]
len(ready_table)
ready_geotable = ready_table.copy() # Prevent SettingwithCopyWarning
# Geocode address locations
from geopy import GoogleV3
geocode = GoogleV3('AIzaSyDNqc0tWzXHx_wIp1w75-XTcCk4BSphB5w').geocode
def get_longitude_latitude(row):
location = geocode(row['formatted_address'])
row['Longitude'] = location.longitude
row['Latitude'] = location.latitude
return row
ready_geotable = ready_geotable.apply(get_longitude_latitude, axis=1)
ready_geotable[:3]
# Set radius for each point
ready_geotable['RadiusInPixelsRange10-20'] = ready_geotable['Total Tree Count within 0.5 Mile']
# Set color for each point using a gradient
ready_geotable['FillReds'] = ready_geotable['Periodic Savings within 0.5 Mile']
# Set color for each point using a rule
# address_geotable['FillColor'] = address_geotable.apply(
# lambda row: 'r' if row['Predicted Graduation Rate'] < 50 else 'g',
# axis=1)
# See what we did
ready_geotable[:3]
# Save file to target folder to include it in the result download
target_path = target_folder + '/b.csv'
address_geotable.to_csv(target_path, index=False)
print(f'b_geotable_path = {target_path}') # Print geotable_path to render map
# %matplotlib inline
# axes = address_table[[
# 'Tree Count Within 100 Meters',
# 'Predicted Graduation Rate',
# ]].plot(kind='bar')
# # Save file to target folder to include it in the result download
# target_path = target_folder + '/c.png'
# figure = axes.get_figure()
# figure.savefig(target_path)
# print(f'c_image_path = {target_path}')
YOUR INTERPRETATION OF THE RESULTS
{a_table : YOUR TABLE NAME ? YOUR TABLE DESCRIPTION}
{b_geotable : YOUR MAP NAME ? YOUR MAP DESCRIPTION}
{c_image : YOUR PLOT NAME ? YOUR PLOT DESCRIPTION}