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 = 'Simplified Table with average monthly savings(within 0.5 Mile) and tree count(within 0.5 Mile).csv'
target_folder = '/tmp'
import subprocess
subprocess.call('pip install geopandas'.split())
from shapely.geometry import Point
import geopandas as gpd
from geopandas import GeoDataFrame
ready_table_path = 'Table with average monthly savings(within 0.5 Mile) and tree count(within 0.5 Mile).csv'
search_radius_in_miles = 0.5
user_address = '28-10 Jackson Ave' # this address can be located
#user_address = '236-238 25TH STREET' # this is an address geocode can't locate
target_folder = '/tmp'
import pandas as pd
ready_table = pd.read_csv(ready_table_path,na_values='n/a')
ready_table.head()
#ready_table = ready_table[['Longitude','Latitude','Total Tree Count within 0.5 Mile','Periodic Savings within 0.5 Mile']]
#ready_table=ready_table
len(ready_table)
import matplotlib.pyplot as plt
plt.scatter(x=ready_table['Longitude'], y=ready_table['Latitude'])
plt.show()
from shapely.geometry import Point
# Combining Lattitude and Longitude to create company geo coordinates:
ready_table['Coordinate'] = ready_table[['Longitude', 'Latitude']].values.tolist()
# Change the coordinates to a geoPoint
ready_table['Coordinate'] = ready_table['Coordinate'].apply(Point)
ready_table[:3]
print(ready_table['Coordinate'][0])
geometry = [Point(xy) for xy in zip(ready_table['Longitude'], ready_table['Latitude'])]
gdf = GeoDataFrame(ready_table, geometry=geometry)
#this is a simple map that goes with geopandas
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
gdf.plot(ax=world.plot(figsize=(10, 6)), marker='o', color='red', markersize=15);
# Set radius for each point
ready_geotable['RadiusInPixelsRange10-20'] = ready_geotable['Total Tree Count within 0.5 Mile']/1000
# Set color for each point using a gradient
ready_geotable['FillReds'] = ready_geotable['Periodic Savings']
# 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'
ready_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}