Best Neighbourhood in Your Budget


Buying a perfect home is a dream for each an every individual. We have been always trying to buy the home which would be perfect for us. For years property consultants and brokers are the people who have helped us in our endeavour.

Now with the addition of new technologies stakeholders have changed their methods to improve their services and in this IT age with the help of technology and data they are trying their best to achieve better results.

So I have decided in my project to make something useful for all the buyers as well the stakeholders in this business. I am using Toronto City data but this project could be expanded to other metropolitan cities as well.

Click here to open notebook in binder
Make sure to make notebook trusted to display map

I am using Foursquare API as well as scraped webpages to get the average property cost in each and every area of Toronto City. As we know cost is the major driver where a person may live.
Foursquare API would be used to get the locality of an area. The locality and venues would be helpful for individual looking to get the best place he needs. For example A bachelor would like to live where there is nearby pubs, entertainment centres and work places. But a person having a family may wants to live where there is nearby schools, shops and parks.

Data Section


We are using FourSquare API, Geocoders, and web Scraping techniques to solve our problem.

FourSquare API would be used to get nearby venues around a location. This venue data would be used to classify our neighbourhood based on the locality.

Geocoders would be used to get latitude and longitude of neighbourhoods. This latitude and longitude is required for maps and FourSquare API.

I searched but couldn't find any structured dataset to get average housing cost in a neighborhood. So I scraped a webpage which shows the average housing cost of a neighborhood. Click here to view webpage

import requests
import pandas as pd
from geopy.geocoders import Nominatim
from IPython.display import HTML, IFrame


url = 'https://www.moneysense.ca/spend/real-estate/where-to-buy-real-estate-in-2020-city-of-toronto/'

header = {
  "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
  "X-Requested-With": "XMLHttpRequest"
}

r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
df=dfs[0]
df
Rank Area Province Neighbourhood Area average price 2019 Value Momentum Average price vs. area Average price vs. metro district Average price vs. greater city area 1-Year price change 5-Year price change Final star rating
0 1 Toronto W06 ON Alderwood $1,012,359 68.23 98.32 150.4% 128.8% 120.0% 65.4% 97.7% ★★★★
1 2 Toronto C08 ON Moss Park $1,509,796 50.49 99.43 173.5% 221.6% 206.5% 80.9% 98.2% ★★★★
2 3 Toronto E01 ON Blake-Jones $1,241,262 60.86 92.39 117.9% 123.8% 115.4% 45.6% 94.6% ★★★
3 4 Toronto C10 ON Mount Pleasant East $1,594,740 51.87 94.85 137.5% 185.5% 172.9% 37.7% 95.1% ★★★★
4 5 Toronto C02 ON Yonge-St. Clair $2,095,964 47.70 86.82 159.7% 283.3% 263.9% 19.5% 87.7% ★★★★★
... ... ... ... ... ... ... ... ... ... ... ... ... ...
136 137 Toronto C01 ON Waterfront Communities C1 $1,648,312 (22.35) 0.00 0.0% 0.0% 0.0% 0 0.0% ★★★
137 138 Toronto C08 ON Waterfront Communities C8 $1,509,796 (22.35) 0.00 0.0% 0.0% 0.0% 0 0.0% ★★★
138 139 Toronto W04 ON Weston $850,365 (22.35) 0.26 0.0% 0.0% 0.0% -100.0% 0.3% ★★
139 140 Toronto C08 ON North St. James Town $1,509,796 (22.35) 0.00 0.0% 0.0% 0.0% 0 0.0% ★★
140 141 Toronto W10 ON Mount Olive-Silverstone-Jamestown $739,999 (22.35) 0.11 0.0% 0.0% 0.0% 0 0.3% ★★

141 rows × 13 columns

Data Cleaning

We are only interested in Area, Neighbourhood and Area average price. Hence we would drop other columns

df=df.filter(items=['Area','Neighbourhood','Area average price 2019'])
df
Area Neighbourhood Area average price 2019
0 Toronto W06 Alderwood $1,012,359
1 Toronto C08 Moss Park $1,509,796
2 Toronto E01 Blake-Jones $1,241,262
3 Toronto C10 Mount Pleasant East $1,594,740
4 Toronto C02 Yonge-St. Clair $2,095,964
... ... ... ...
136 Toronto C01 Waterfront Communities C1 $1,648,312
137 Toronto C08 Waterfront Communities C8 $1,509,796
138 Toronto W04 Weston $850,365
139 Toronto C08 North St. James Town $1,509,796
140 Toronto W10 Mount Olive-Silverstone-Jamestown $739,999

141 rows × 3 columns

The average price is in object type hence it needs to be converted to float

df[df.columns[2]] = df[df.columns[2]].replace('[\$,]', '', regex=True).astype(float)
df
Area Neighbourhood Area average price 2019
0 Toronto W06 Alderwood 1012359.0
1 Toronto C08 Moss Park 1509796.0
2 Toronto E01 Blake-Jones 1241262.0
3 Toronto C10 Mount Pleasant East 1594740.0
4 Toronto C02 Yonge-St. Clair 2095964.0
... ... ... ...
136 Toronto C01 Waterfront Communities C1 1648312.0
137 Toronto C08 Waterfront Communities C8 1509796.0
138 Toronto W04 Weston 850365.0
139 Toronto C08 North St. James Town 1509796.0
140 Toronto W10 Mount Olive-Silverstone-Jamestown 739999.0

141 rows × 3 columns

Using geocode to get latitude and longitude of a neighbourhood

# place=place+ ' Toronto'
# place
index=0
latitude=[]
longitude=[]
geolocator = Nominatim(user_agent="toronto")
for i in df['Neighbourhood'].iteritems():
            address = i[1] + ' Toronto'
            location = geolocator.geocode(address)
            if(location is None):
                df.drop([index],inplace=True)
                index=index+1
                continue
            lat = location.latitude
            long = location.longitude
            index=index+1
            latitude.append(lat)
            longitude.append(long)
df['Latitude']=latitude
df['Longitude']=longitude
df
Area Neighbourhood Area average price 2019 Latitude Longitude
0 Toronto W06 Alderwood 1012359.0 43.601717 -79.545232
1 Toronto C08 Moss Park 1509796.0 43.654644 -79.369728
3 Toronto C10 Mount Pleasant East 1594740.0 43.708417 -79.390135
4 Toronto C02 Yonge-St. Clair 2095964.0 43.688078 -79.394396
5 Toronto C02 Wychwood 2095964.0 43.682171 -79.423113
... ... ... ... ... ...
133 Toronto E10 Highland Creek 790226.0 43.790117 -79.173334
134 Toronto E09 Morningside 727426.0 43.782601 -79.204958
135 Toronto W10 Elms-Old Rexdale 739999.0 43.721770 -79.552173
138 Toronto W04 Weston 850365.0 43.700161 -79.516247
139 Toronto C08 North St. James Town 1509796.0 43.669403 -79.372704

110 rows × 5 columns

Now we will visualize our Data

df_price=df[['Neighbourhood','Area average price 2019']]
df_price.set_index('Neighbourhood',inplace=True)
%matplotlib inline 

import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as colors

mpl.style.use('ggplot') # optional: for ggplot-like style

# check for latest version of Matplotlib
print ('Matplotlib version: ', mpl.__version__) # >= 2.0.0
Matplotlib version:  3.1.3
df_price.plot(kind='hist',figsize=(16,8),color='grey')
<matplotlib.axes._subplots.AxesSubplot at 0x22a8991a588>
df_price.plot(kind='bar',figsize=(16,8))
plt.title("Price Distribution by Neigbourhood")
plt.ylabel('Price in $')
Text(0, 0.5, 'Price in $')
df_price.describe()
Area average price 2019
count 1.100000e+02
mean 1.220273e+06
std 4.243845e+05
min 7.222090e+05
25% 8.453160e+05
50% 1.184223e+06
75% 1.526647e+06
max 3.008096e+06
df_price.plot(kind='box',figsize=(10,7),color='blue')
plt.title("Price Distribution")
plt.ylabel('Price in $')
Text(0, 0.5, 'Price in $')

Now we are using folium to demonstrate the data points on map with labels demonstrating average price and neighborhood

import folium
location = geolocator.geocode('Toronto')
latitude = location.latitude
longitude = location.longitude
# create map of New York using latitude and longitude values
map_toronto = folium.Map(location=[latitude, longitude], zoom_start=10)

# add markers to map
for lat, lng, neighbourhood,price in zip(df['Latitude'], df['Longitude'], df['Neighbourhood'],df['Area average price 2019']):
    label = '{}, {}'.format(neighbourhood,price )
    label = folium.Popup(label, parse_html=True)
    folium.CircleMarker(
        [lat, lng],
        radius=5,
        popup=label,
        color='blue',
        fill=True,
        fill_color='#3186cc',
        fill_opacity=0.7,
        parse_html=False).add_to(map_toronto)  
map_toronto.save('map_toronto.html')

Now we will use FourSquare API to get nearby venues

df_new=df_price.reset_index()
df_new
Neighbourhood Area average price 2019
0 Alderwood 1012359.0
1 Moss Park 1509796.0
2 Mount Pleasant East 1594740.0
3 Yonge-St. Clair 2095964.0
4 Wychwood 2095964.0
... ... ...
105 Highland Creek 790226.0
106 Morningside 727426.0
107 Elms-Old Rexdale 739999.0
108 Weston 850365.0
109 North St. James Town 1509796.0

110 rows × 2 columns

geo = 'toronto_crs84.geojson' # geojson file

# create a plain world map
map1 = folium.Map(location=[43.718432, -79.333204], zoom_start=11)
map1.choropleth(
    geo_data=geo,
    data=df_new,
    columns=['Neighbourhood', 'Area average price 2019'],
    key_on='feature.properties.AREA_NAME',
    fill_color='YlOrRd', 
    fill_opacity=0.7, 
    line_opacity=0.2,
    legend_name='Average Price in Toronto',
    
)
map1.save('map1.html')
CLIENT_ID = 'xxx' # your Foursquare ID
CLIENT_SECRET = 'xxx' # your Foursquare Secret
ACCESS_TOKEN = 'xxx' # your FourSquare Access Token
VERSION = '20180604'
LIMIT = 100 # A default Foursquare API limit value

Function to extract useful response

def get_category_type(row):
    try:
        categories_list = row['categories']
    except:
        categories_list = row['venue.categories']
        
    if len(categories_list) == 0:
        return None
    else:
        return categories_list[0]['name']

Getting nearby venues from each neighbourhood

def getNearbyVenues(names, latitudes, longitudes, radius=500):
    
    venues_list=[]
    for name, lat, lng in zip(names, latitudes, longitudes):
        print(name)
            
        # create the API request URL
        url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(
            CLIENT_ID, 
            CLIENT_SECRET, 
            VERSION, 
            lat, 
            lng, 
            radius, 
            LIMIT)
            
        # make the GET request
        results = requests.get(url).json()["response"]['groups'][0]['items']
        
        # return only relevant information for each nearby venue
        venues_list.append([(
            name, 
            lat, 
            lng, 
            v['venue']['name'], 
            v['venue']['location']['lat'], 
            v['venue']['location']['lng'],  
            v['venue']['categories'][0]['name']) for v in results])

    nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
    nearby_venues.columns = ['Neighborhood', 
                  'Neighborhood Latitude', 
                  'Neighborhood Longitude', 
                  'Venue', 
                  'Venue Latitude', 
                  'Venue Longitude', 
                  'Venue Category']
    
    return(nearby_venues)
df.rename(columns={"Neighbourhood":"Neighborhood"},inplace=True)
toronto_venues = getNearbyVenues(names=df['Neighborhood'],
                                   latitudes=df['Latitude'],
                                   longitudes=df['Longitude']
                                  )
Alderwood
Moss Park
Mount Pleasant East
Yonge-St. Clair
Wychwood
Crescent Town
Lawrence Park North
Oakwood-Vaughan
Rosedale-Moore Park
West Hill
Trinity-Bellwoods
Yonge-Eglinton
Palmerston-Little Italy
New Toronto
Annex
Rouge E11
East End-Danforth
York University Heights
Little Portugal
Roncesvalles
Humber Summit
Kennedy Park
Malvern
Keelesdale-Eglinton West
Mount Pleasant West
Glenfield-Jane Heights
Banbury-Don Mills
Mimico
Hillcrest Village
Dufferin Grove
Bendale
Corso Italia-Davenport
Victoria Village
Broadview North
Oakridge
High Park North
Danforth Village-East York
Black Creek
Rouge E10
North Riverdale
Mount Dennis
The Beaches
Ionview
High Park-Swansea
South Riverdale
Casa Loma
Runnymede-Bloor West Village
West Humber-Clairville
Dovercourt-Wallace Emerson-Junction
Leaside
Tam O'Shanter-Sullivan
Newtonbrook West
Lawrence Park South
Pleasant View
Agincourt North
Playter Estates-Danforth
Thistletown-Beaumonde Heights
Danforth
East York
Long Branch
Humewood-Cedarvale
Centennial Scarborough
Dorset Park
Don Valley Village
Bayview Woods-Steeles
Junction Area
Woburn
University
Milliken
L'Amoreaux
Cabbagetown-South St. James Town
Maple Leaf
Guildwood
Rustic
Church-Yonge Corridor
Forest Hill South
Forest Hill North
Kingsway South
Flemingdon Park
Islington-City Centre West
Bayview Village
Regent Park
Willowdale West
Stonegate-Queensway
Edenbridge-Humber Valley
Englemount-Lawrence
Newtonbrook East
Etobicoke West Mall
Markland Wood
South Parkdale
Willowdale East
Niagara
Bathurst Manor
St. Andrew-Windfields
Henry Farm
Lansing-Westgate
Humber Heights
Clanton Park
Yorkdale-Glen Park
O'Connor-Parkview
Cliffcrest
Scarborough Village
Eglinton East
Steeles
Rexdale-Kipling
Highland Creek
Morningside
Elms-Old Rexdale
Weston
North St. James Town
toronto_venues.head()
Neighborhood Neighborhood Latitude Neighborhood Longitude Venue Venue Latitude Venue Longitude Venue Category
0 Alderwood 43.601717 -79.545232 Il Paesano Pizzeria & Restaurant 43.601280 -79.545028 Pizza Place
1 Alderwood 43.601717 -79.545232 Timothy's Pub 43.600165 -79.544699 Pub
2 Alderwood 43.601717 -79.545232 Toronto Gymnastics International 43.599832 -79.542924 Gym
3 Alderwood 43.601717 -79.545232 Tim Hortons 43.602396 -79.545048 Coffee Shop
4 Alderwood 43.601717 -79.545232 Pizza Pizza 43.605340 -79.547252 Pizza Place

Now getting the returned venues from each neighborhood.

toronto_venues.groupby('Neighborhood').count()
Neighborhood Latitude Neighborhood Longitude Venue Venue Latitude Venue Longitude Venue Category
Neighborhood
Agincourt North 25 25 25 25 25 25
Alderwood 7 7 7 7 7 7
Annex 38 38 38 38 38 38
Banbury-Don Mills 4 4 4 4 4 4
Bathurst Manor 71 71 71 71 71 71
... ... ... ... ... ... ...
Wychwood 44 44 44 44 44 44
Yonge-Eglinton 68 68 68 68 68 68
Yonge-St. Clair 58 58 58 58 58 58
York University Heights 16 16 16 16 16 16
Yorkdale-Glen Park 15 15 15 15 15 15

110 rows × 6 columns

print('There are {} uniques categories.'.format(len(toronto_venues['Venue Category'].unique())))
There are 268 uniques categories.

Now we would use dummy variables to use our Model

# one hot encoding
toronto_onehot = pd.get_dummies(toronto_venues[['Venue Category']], prefix="", prefix_sep="")

# add neighborhood column back to dataframe
toronto_onehot['Neighborhood'] = toronto_venues['Neighborhood'] 

# move neighborhood column to the first column
fixed_columns = [toronto_onehot.columns[-1]] + list(toronto_onehot.columns[:-1])
toronto_onehot = toronto_onehot[fixed_columns]

toronto_onehot.head()
Yoga Studio ATM Accessories Store Adult Boutique African Restaurant American Restaurant Animal Shelter Antique Shop Argentinian Restaurant Art Gallery ... Tree Turkish Restaurant Vegetarian / Vegan Restaurant Video Game Store Video Store Vietnamese Restaurant Whisky Bar Wine Bar Wings Joint Women's Store
0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0

5 rows × 268 columns

toronto_onehot.shape
(2353, 268)
toronto_grouped = toronto_onehot.groupby('Neighborhood').mean().reset_index()
# toronto_grouped =pd.merge(toronto_grouped,df2,on='Neighborhood')
toronto_grouped
Neighborhood Yoga Studio ATM Accessories Store Adult Boutique African Restaurant American Restaurant Animal Shelter Antique Shop Argentinian Restaurant ... Tree Turkish Restaurant Vegetarian / Vegan Restaurant Video Game Store Video Store Vietnamese Restaurant Whisky Bar Wine Bar Wings Joint Women's Store
0 Agincourt North 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 ... 0.0 0.0 0.000000 0.000000 0.000000 0.040000 0.0 0.000000 0.000000 0.0
1 Alderwood 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 ... 0.0 0.0 0.000000 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0
2 Annex 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 ... 0.0 0.0 0.026316 0.000000 0.000000 0.000000 0.0 0.000000 0.026316 0.0
3 Banbury-Don Mills 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 ... 0.0 0.0 0.000000 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0
4 Bathurst Manor 0.000000 0.0 0.0 0.0 0.0 0.014085 0.0 0.0 0.000000 ... 0.0 0.0 0.014085 0.000000 0.028169 0.014085 0.0 0.000000 0.000000 0.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
105 Wychwood 0.022727 0.0 0.0 0.0 0.0 0.022727 0.0 0.0 0.000000 ... 0.0 0.0 0.000000 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0
106 Yonge-Eglinton 0.014706 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 ... 0.0 0.0 0.014706 0.014706 0.000000 0.014706 0.0 0.014706 0.000000 0.0
107 Yonge-St. Clair 0.017241 0.0 0.0 0.0 0.0 0.017241 0.0 0.0 0.000000 ... 0.0 0.0 0.000000 0.000000 0.000000 0.017241 0.0 0.000000 0.000000 0.0
108 York University Heights 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 ... 0.0 0.0 0.000000 0.000000 0.000000 0.062500 0.0 0.000000 0.000000 0.0
109 Yorkdale-Glen Park 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.066667 ... 0.0 0.0 0.000000 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0

110 rows × 268 columns

Getting Most common Venues

def return_most_common_venues(row, num_top_venues):
    row_categories = row.iloc[1:]
    row_categories_sorted = row_categories.sort_values(ascending=False)
    
    return row_categories_sorted.index.values[0:num_top_venues]
import numpy as np
num_top_venues = 10

indicators = ['st', 'nd', 'rd']

# create columns according to number of top venues
columns = ['Neighborhood']
for ind in np.arange(num_top_venues):
    try:
        columns.append('{}{} Most Common Venue'.format(ind+1, indicators[ind]))
    except:
        columns.append('{}th Most Common Venue'.format(ind+1))

# create a new dataframe
neighborhoods_venues_sorted = pd.DataFrame(columns=columns)
neighborhoods_venues_sorted['Neighborhood'] = toronto_grouped['Neighborhood']

for ind in np.arange(toronto_grouped.shape[0]):
    neighborhoods_venues_sorted.iloc[ind, 1:] = return_most_common_venues(toronto_grouped.iloc[ind, :], num_top_venues)

neighborhoods_venues_sorted.head()
Neighborhood 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
0 Agincourt North Chinese Restaurant Bank Fast Food Restaurant Japanese Restaurant Beer Store Sporting Goods Shop Fried Chicken Joint Spa Restaurant Bakery
1 Alderwood Pizza Place Pub Pharmacy Coffee Shop Dance Studio Gym Eastern European Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant
2 Annex Pizza Place Indian Restaurant Thai Restaurant Gym Bistro Diner Coffee Shop Sandwich Place Korean Restaurant Sushi Restaurant
3 Banbury-Don Mills Japanese Restaurant Gas Station Intersection Park Farmers Market Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant
4 Bathurst Manor Korean Restaurant Grocery Store Coffee Shop Café Bakery Mexican Restaurant Bar Eastern European Restaurant Bubble Tea Shop Video Store

Final Dataset Used for clustering

toronto_grouped=pd.merge(toronto_grouped,df,on='Neighborhood')
toronto_grouped_clustering = toronto_grouped.drop(['Neighborhood','Area'],axis= 1)
toronto_grouped_clustering
Yoga Studio ATM Accessories Store Adult Boutique African Restaurant American Restaurant Animal Shelter Antique Shop Argentinian Restaurant Art Gallery ... Video Game Store Video Store Vietnamese Restaurant Whisky Bar Wine Bar Wings Joint Women's Store Area average price 2019 Latitude Longitude
0 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.040000 0.0 0.000000 0.000000 0.0 831826.0 43.808038 -79.266439
1 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0 1012359.0 43.601717 -79.545232
2 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.0 0.000000 0.026316 0.0 2095964.0 43.670338 -79.407117
3 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0 1187598.0 43.752683 -79.365270
4 0.000000 0.0 0.0 0.0 0.0 0.014085 0.0 0.0 0.000000 0.000000 ... 0.000000 0.028169 0.014085 0.0 0.000000 0.000000 0.0 1089948.0 43.665519 -79.411937
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
105 0.022727 0.0 0.0 0.0 0.0 0.022727 0.0 0.0 0.000000 0.022727 ... 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0 2095964.0 43.682171 -79.423113
106 0.014706 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 0.000000 ... 0.014706 0.000000 0.014706 0.0 0.014706 0.000000 0.0 1672260.0 43.706748 -79.398327
107 0.017241 0.0 0.0 0.0 0.0 0.017241 0.0 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.017241 0.0 0.000000 0.000000 0.0 2095964.0 43.688078 -79.394396
108 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.000000 0.000000 ... 0.000000 0.000000 0.062500 0.0 0.000000 0.000000 0.0 828052.0 43.758781 -79.519434
109 0.000000 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.066667 0.000000 ... 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 0.0 850365.0 43.703434 -79.452918

110 rows × 270 columns

from sklearn.cluster import KMeans

kclusters = 4
kmeans = KMeans(n_clusters=kclusters, random_state=0).fit(toronto_grouped_clustering)

# check cluster labels generated for each row in the dataframe
kmeans.labels_[0:]
array([3, 1, 0, 1, 1, 1, 1, 3, 3, 1, 2, 0, 3, 2, 1, 3, 3, 1, 1, 1, 1, 3,
       1, 2, 1, 1, 1, 3, 3, 2, 1, 2, 2, 2, 3, 3, 1, 1, 2, 3, 1, 3, 3, 2,
       3, 1, 1, 3, 3, 1, 3, 1, 2, 2, 2, 2, 1, 3, 3, 1, 3, 1, 3, 2, 3, 2,
       2, 1, 2, 1, 2, 1, 2, 1, 3, 2, 2, 1, 1, 2, 3, 2, 0, 3, 3, 1, 3, 3,
       2, 1, 0, 3, 1, 3, 1, 3, 2, 2, 1, 3, 3, 3, 2, 1, 3, 0, 2, 0, 3, 3])
neighborhoods_venues_sorted.insert(0, 'Cluster Labels', kmeans.labels_)

toronto_merged = df

# merge manhattan_grouped with manhattan_data to add latitude/longitude for each neighborhood
toronto_merged = toronto_merged.join(neighborhoods_venues_sorted.set_index('Neighborhood'), on='Neighborhood')

toronto_merged.head() # check the last columns!
Area Neighborhood Area average price 2019 Latitude Longitude Cluster Labels 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
0 Toronto W06 Alderwood 1012359.0 43.601717 -79.545232 1 Pizza Place Pub Pharmacy Coffee Shop Dance Studio Gym Eastern European Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant
1 Toronto C08 Moss Park 1509796.0 43.654644 -79.369728 2 Coffee Shop Café Furniture / Home Store Italian Restaurant Diner Sandwich Place Grocery Store Yoga Studio Karaoke Bar Sushi Restaurant
3 Toronto C10 Mount Pleasant East 1594740.0 43.708417 -79.390135 2 Pizza Place Coffee Shop Dessert Shop Italian Restaurant Gym Sushi Restaurant Café Ramen Restaurant Taco Place Supermarket
4 Toronto C02 Yonge-St. Clair 2095964.0 43.688078 -79.394396 0 Coffee Shop Italian Restaurant Sushi Restaurant Pizza Place Sandwich Place Thai Restaurant Grocery Store Bagel Shop Bank Café
5 Toronto C02 Wychwood 2095964.0 43.682171 -79.423113 0 Ice Cream Shop Café Italian Restaurant Sushi Restaurant Restaurant Coffee Shop Bakery Pizza Place Yoga Studio Moving Target
map_clusters = folium.Map(location=[latitude, longitude], zoom_start=10)

# set color scheme for the clusters
x = np.arange(kclusters)
ys = [i + x + (i*x)**2 for i in range(kclusters)]
colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]

# add markers to the map
markers_colors = []
for lat, lon, poi, cluster in zip(toronto_merged['Latitude'], toronto_merged['Longitude'], toronto_merged['Neighborhood'], toronto_merged['Cluster Labels']):
    label = folium.Popup(str(poi) + ' Cluster ' + str(cluster), parse_html=True)
    folium.CircleMarker(
        [lat, lon],
        radius=5,
        popup=label,
        color=rainbow[cluster-1],
        fill=True,
        fill_color=rainbow[cluster-1],
        fill_opacity=0.7).add_to(map_clusters)
    
map_clusters.save('map_cluster.html')
toronto_merged.loc[toronto_merged['Cluster Labels']==0]
Area Neighborhood Area average price 2019 Latitude Longitude Cluster Labels 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
4 Toronto C02 Yonge-St. Clair 2095964.0 43.688078 -79.394396 0 Coffee Shop Italian Restaurant Sushi Restaurant Pizza Place Sandwich Place Thai Restaurant Grocery Store Bagel Shop Bank Café
5 Toronto C02 Wychwood 2095964.0 43.682171 -79.423113 0 Ice Cream Shop Café Italian Restaurant Sushi Restaurant Restaurant Coffee Shop Bakery Pizza Place Yoga Studio Moving Target
9 Toronto C09 Rosedale-Moore Park 3008096.0 43.690388 -79.383297 0 Gym Women's Store Falafel Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Farmers Market Dumpling Restaurant
16 Toronto C02 Annex 2095964.0 43.670338 -79.407117 0 Pizza Place Indian Restaurant Thai Restaurant Gym Bistro Diner Coffee Shop Sandwich Place Korean Restaurant Sushi Restaurant
63 Toronto C02 Casa Loma 2095964.0 43.678101 -79.409416 0 Sandwich Place History Museum Coffee Shop Café Theater Donut Shop Cheese Shop Castle Museum Modern European Restaurant
116 Toronto C12 St. Andrew-Windfields 2408769.0 43.647792 -79.384871 0 Coffee Shop Café Hotel Asian Restaurant Gym American Restaurant Seafood Restaurant Taco Place Salad Place Salon / Barbershop
toronto_merged.loc[toronto_merged['Cluster Labels']==1]
Area Neighborhood Area average price 2019 Latitude Longitude Cluster Labels 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
0 Toronto W06 Alderwood 1012359.0 43.601717 -79.545232 1 Pizza Place Pub Pharmacy Coffee Shop Dance Studio Gym Eastern European Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant
6 Toronto E03 Crescent Town 1069340.0 43.695403 -79.293099 1 Convenience Store Golf Course Park Metro Station History Museum Donut Shop Fish & Chips Shop Filipino Restaurant Field Fast Food Restaurant
14 Toronto W06 New Toronto 1012359.0 43.600763 -79.505264 1 Mexican Restaurant Café Italian Restaurant Scenic Lookout Fried Chicken Joint Sushi Restaurant Restaurant Bakery Dessert Shop Asian Restaurant
18 Toronto E02 East End-Danforth 1316352.0 43.668440 -79.330670 1 Pizza Place Indie Theater Mexican Restaurant Café Coffee Shop Park Egyptian Restaurant Skating Rink Burger Joint Platform
34 Toronto C13 Banbury-Don Mills 1187598.0 43.752683 -79.365270 1 Japanese Restaurant Gas Station Intersection Park Farmers Market Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant
35 Toronto W06 Mimico 1012359.0 43.616677 -79.496805 1 Bar Playground Performing Arts Venue Skating Rink Bakery Women's Store Falafel Restaurant Electronics Store Ethiopian Restaurant Event Space
37 Toronto C15 Hillcrest Village 1193437.5 43.681695 -79.425712 1 Italian Restaurant Indian Restaurant Bakery Sushi Restaurant Café Mexican Restaurant Restaurant Coffee Shop Dance Studio Juice Bar
42 Toronto C13 Victoria Village 1187598.0 43.732658 -79.311189 1 Park Mediterranean Restaurant Middle Eastern Restaurant Thai Restaurant Falafel Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory
43 Toronto E03 Broadview North 1069340.0 43.683932 -79.356950 1 Other Great Outdoors Bus Line Theater Grocery Store Discount Store Coffee Shop Intersection Park Ice Cream Shop Fast Food Restaurant
45 Toronto W02 High Park North 1252811.0 43.657383 -79.470961 1 Park Tennis Court Baseball Field Gym / Fitness Center Convenience Store Mattress Store Filipino Restaurant Field Fast Food Restaurant Farmers Market
48 Toronto E03 Danforth Village-East York 1069340.0 43.683357 -79.323574 1 Café Bar American Restaurant Ethiopian Restaurant Gastropub Coffee Shop Pizza Place Metro Station Bus Station Mexican Restaurant
53 Toronto E01 North Riverdale 1241262.0 43.665470 -79.352594 1 Vietnamese Restaurant Bakery Chinese Restaurant Grocery Store Fast Food Restaurant Bridal Shop French Restaurant Café Moving Target Baseball Field
56 Toronto E02 The Beaches 1316352.0 43.671024 -79.296712 1 Beach Nail Salon Breakfast Spot Pub Pizza Place Bar Park Japanese Restaurant Liquor Store Café
62 Toronto E01 South Riverdale 1241262.0 43.665470 -79.352594 1 Vietnamese Restaurant Bakery Chinese Restaurant Grocery Store Fast Food Restaurant Bridal Shop French Restaurant Café Moving Target Baseball Field
64 Toronto W02 Runnymede-Bloor West Village 1252811.0 43.651778 -79.475923 1 Coffee Shop Café Bakery Bank Pizza Place Thai Restaurant Bookstore Pub Flower Shop Restaurant
66 Toronto W02 Dovercourt-Wallace Emerson-Junction 1252811.0 43.667330 -79.438106 1 Park Bakery Pet Store Pool Middle Eastern Restaurant Brewery Liquor Store Sporting Goods Shop Music Venue Furniture / Home Store
69 Toronto C07 Newtonbrook West 1263135.0 43.795986 -79.413090 1 Middle Eastern Restaurant Greek Restaurant Korean Restaurant Thai Restaurant Fish & Chips Shop Filipino Restaurant Field Fast Food Restaurant Farmers Market Dumpling Restaurant
71 Toronto C15 Pleasant View 1193437.5 43.787048 -79.333714 1 Convenience Store Italian Restaurant Shopping Mall Burger Joint Breakfast Spot Fast Food Restaurant Restaurant Bank Thrift / Vintage Store Japanese Restaurant
73 Toronto E03 Playter Estates-Danforth 1069340.0 43.678666 -79.355518 1 Greek Restaurant Coffee Shop Pub Café Ice Cream Shop Italian Restaurant Restaurant Yoga Studio Juice Bar Bubble Tea Shop
75 Toronto E03 Danforth 1069340.0 43.686433 -79.300355 1 Bus Line Pharmacy Grocery Store Coffee Shop Fish & Chips Shop BBQ Joint Skating Rink Mexican Restaurant Middle Eastern Restaurant Sandwich Place
76 Toronto E03 East York 1069340.0 43.699971 -79.332520 1 Park Restaurant Plaza Liquor Store Pastry Shop Intersection Pub Greek Restaurant Ethiopian Restaurant Dumpling Restaurant
77 Toronto W06 Long Branch 1012359.0 43.592005 -79.545365 1 South American Restaurant Burrito Place Café Light Rail Station Trail Seafood Restaurant Discount Store Park Burger Joint Hobby Shop
81 Toronto C15 Don Valley Village 1193437.5 43.792673 -79.354722 1 Sandwich Place Coffee Shop Bank Pizza Place Grocery Store Pharmacy Intersection Eastern European Restaurant Egyptian Restaurant Electronics Store
82 Toronto C15 Bayview Woods-Steeles 1193437.5 43.798127 -79.382973 1 Dog Run Women's Store Farmers Market Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant Fast Food Restaurant Eastern European Restaurant
83 Toronto W02 Junction Area 1252811.0 43.665478 -79.470352 1 Mexican Restaurant Coffee Shop Café Italian Restaurant Bar Thai Restaurant Nail Salon Discount Store Grocery Store Arts & Crafts Store
97 Toronto W08 Kingsway South 1184223.0 43.647381 -79.511333 1 Coffee Shop Italian Restaurant Sushi Restaurant Breakfast Spot Bank Pub Dessert Shop Grocery Store Greek Restaurant French Restaurant
99 Toronto W08 Islington-City Centre West 1184223.0 43.645335 -79.524816 1 Coffee Shop Bakery Fast Food Restaurant Sandwich Place Sushi Restaurant Pub Gluten-free Restaurant Bus Stop Beer Store Restaurant
100 Toronto C15 Bayview Village 1193437.5 43.769197 -79.376662 1 Bank Pizza Place Persian Restaurant Outdoor Supply Store Sandwich Place Fast Food Restaurant Burger Joint Fish Market Sporting Goods Shop Gas Station
103 Toronto C07 Willowdale West 1263135.0 43.761510 -79.410923 1 Coffee Shop Grocery Store Japanese Restaurant Gym Gas Station Burger Joint Korean Restaurant Fried Chicken Joint Fast Food Restaurant Sandwich Place
104 Toronto W07 Stonegate-Queensway 1225390.0 43.621950 -79.523499 1 Optical Shop Burrito Place Bank Yoga Studio Asian Restaurant Eastern European Restaurant Restaurant Middle Eastern Restaurant Shopping Mall Buffet
105 Toronto W08 Edenbridge-Humber Valley 1184223.0 43.670672 -79.518855 1 Indian Restaurant Garden Park Women's Store Factory Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Falafel Restaurant
110 Toronto W08 Etobicoke West Mall 1184223.0 43.643549 -79.565325 1 Hotel Clothing Store Breakfast Spot Farmers Market Café Sandwich Place Bank Mexican Restaurant Grocery Store Restaurant
111 Toronto W08 Markland Wood 1184223.0 43.631239 -79.585434 1 Park Piano Bar Golf Course Baseball Field Falafel Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Women's Store
115 Toronto C06 Bathurst Manor 1089948.0 43.665519 -79.411937 1 Korean Restaurant Grocery Store Coffee Shop Café Bakery Mexican Restaurant Bar Eastern European Restaurant Bubble Tea Shop Video Store
117 Toronto C15 Henry Farm 1193437.5 43.769509 -79.354296 1 Park Lawyer Intersection Tennis Court Women's Store Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory
118 Toronto C07 Lansing-Westgate 1263135.0 43.758950 -79.422556 1 Health & Beauty Service Spa Business Service Farmers Market Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant Women's Store
122 Toronto C06 Clanton Park 1089948.0 43.744124 -79.447146 1 Home Service Park Other Repair Shop IT Services Adult Boutique Food Flea Market Fish Market Fish & Chips Shop Filipino Restaurant
124 Toronto E03 O'Connor-Parkview 1069340.0 43.702390 -79.316098 1 Pizza Place Pharmacy Flea Market Intersection Gastropub Bank Filipino Restaurant Fish & Chips Shop Field Eastern European Restaurant
toronto_merged.loc[toronto_merged['Cluster Labels']==2]
Area Neighborhood Area average price 2019 Latitude Longitude Cluster Labels 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
1 Toronto C08 Moss Park 1509796.0 43.654644 -79.369728 2 Coffee Shop Café Furniture / Home Store Italian Restaurant Diner Sandwich Place Grocery Store Yoga Studio Karaoke Bar Sushi Restaurant
3 Toronto C10 Mount Pleasant East 1594740.0 43.708417 -79.390135 2 Pizza Place Coffee Shop Dessert Shop Italian Restaurant Gym Sushi Restaurant Café Ramen Restaurant Taco Place Supermarket
7 Toronto C04 Lawrence Park North 1819957.0 43.729199 -79.403252 2 Sushi Restaurant Bakery Coffee Shop Italian Restaurant Bank Fast Food Restaurant Cosmetics Shop Pub Asian Restaurant Pizza Place
8 Toronto C03 Oakwood-Vaughan 1672260.0 43.682857 -79.419540 2 Coffee Shop Pizza Place Ice Cream Shop Yoga Studio Restaurant Latin American Restaurant Frozen Yogurt Shop Caribbean Restaurant Liquor Store Food & Drink Shop
11 Toronto C01 Trinity-Bellwoods 1648312.0 43.645482 -79.413249 2 Men's Store Coffee Shop Yoga Studio Café Vietnamese Restaurant Dessert Shop Bakery Bar Boutique Park
12 Toronto C03 Yonge-Eglinton 1672260.0 43.706748 -79.398327 2 Coffee Shop Italian Restaurant Pub Grocery Store Bookstore Gym Restaurant Movie Theater Bakery Fast Food Restaurant
13 Toronto C01 Palmerston-Little Italy 1648312.0 43.660065 -79.411806 2 Café Park Asian Restaurant Salon / Barbershop French Restaurant Furniture / Home Store Donut Shop Cheese Shop Taco Place Tapas Restaurant
21 Toronto C01 Little Portugal 1648312.0 43.647413 -79.431116 2 Bar Café Coffee Shop Bakery Restaurant Cocktail Bar Korean Restaurant Jazz Club Dive Bar Nightclub
23 Toronto W01 Roncesvalles 1526647.0 43.651443 -79.451038 2 Café Gourmet Shop Bookstore Breakfast Spot Restaurant Gift Shop Sandwich Place Sushi Restaurant Sports Bar Liquor Store
31 Toronto C10 Mount Pleasant West 1594740.0 43.708417 -79.390135 2 Pizza Place Coffee Shop Dessert Shop Italian Restaurant Gym Sushi Restaurant Café Ramen Restaurant Taco Place Supermarket
38 Toronto C01 Dufferin Grove 1648312.0 43.653632 -79.426439 2 Bar Coffee Shop Italian Restaurant Restaurant Mexican Restaurant Sports Bar Convenience Store Bookstore Breakfast Spot Café
61 Toronto W01 High Park-Swansea 1526647.0 43.638093 -79.466584 2 Park Light Rail Station Gym / Fitness Center Lake Bus Stop Gas Station Beach Trail Building American Restaurant
67 Toronto C11 Leaside 1694183.0 43.704798 -79.368090 2 Convenience Store Park Japanese Restaurant Sandwich Place Fish Market Fish & Chips Shop Filipino Restaurant Field Fast Food Restaurant Farmers Market
70 Toronto C04 Lawrence Park South 1819957.0 43.729199 -79.403252 2 Sushi Restaurant Bakery Coffee Shop Italian Restaurant Bank Fast Food Restaurant Cosmetics Shop Pub Asian Restaurant Pizza Place
78 Toronto C03 Humewood-Cedarvale 1672260.0 43.688322 -79.428080 2 Convenience Store Trail Field Soccer Stadium Hockey Arena Creperie Eastern European Restaurant Flea Market Fish Market Fish & Chips Shop
85 Toronto C01 University 1648312.0 43.656119 -79.384670 2 Coffee Shop Clothing Store Restaurant Cosmetics Shop Middle Eastern Restaurant Sandwich Place Pizza Place Bubble Tea Shop Diner Hotel
90 Toronto C08 Cabbagetown-South St. James Town 1509796.0 43.666847 -79.369179 2 Coffee Shop Pizza Place Restaurant Bakery Pet Store Indian Restaurant Café Gastropub Japanese Restaurant Italian Restaurant
94 Toronto C08 Church-Yonge Corridor 1509796.0 43.671877 -79.386666 2 Café Italian Restaurant Coffee Shop French Restaurant Sushi Restaurant Spa Japanese Restaurant Indian Restaurant Boutique Gourmet Shop
95 Toronto C03 Forest Hill South 1672260.0 43.693559 -79.413902 2 Park Playground Bank Business Service Falafel Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Women's Store
96 Toronto C04 Forest Hill North 1819957.0 43.693559 -79.413902 2 Park Playground Bank Business Service Falafel Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Women's Store
98 Toronto C10 Flemingdon Park 1594740.0 43.718432 -79.333204 2 Coffee Shop Pharmacy Movie Theater Science Museum Pakistani Restaurant Nightclub Grocery Store Gym Japanese Restaurant Bus Line
102 Toronto C08 Regent Park 1509796.0 43.660706 -79.360457 2 Coffee Shop Restaurant Thai Restaurant Grocery Store Beer Store Pub Electronics Store Food Truck Auto Dealership Pool
107 Toronto C04 Englemount-Lawrence 1819957.0 43.711594 -79.436001 2 Shoe Store Coffee Shop Bakery Tennis Court Shopping Mall Metro Station Field Filipino Restaurant Fast Food Restaurant Fish & Chips Shop
108 Toronto C14 Newtonbrook East 1529290.0 43.795986 -79.413090 2 Middle Eastern Restaurant Greek Restaurant Korean Restaurant Thai Restaurant Fish & Chips Shop Filipino Restaurant Field Fast Food Restaurant Farmers Market Dumpling Restaurant
112 Toronto W01 South Parkdale 1526647.0 43.638093 -79.466584 2 Park Light Rail Station Gym / Fitness Center Lake Bus Stop Gas Station Beach Trail Building American Restaurant
113 Toronto C14 Willowdale East 1529290.0 43.761510 -79.410923 2 Coffee Shop Grocery Store Japanese Restaurant Gym Gas Station Burger Joint Korean Restaurant Fried Chicken Joint Fast Food Restaurant Sandwich Place
114 Toronto C01 Niagara 1648312.0 43.644075 -79.408698 2 Yoga Studio Bakery Dessert Shop Café Pizza Place Burger Joint Spa Middle Eastern Restaurant Salon / Barbershop Salad Place
139 Toronto C08 North St. James Town 1509796.0 43.669403 -79.372704 2 Coffee Shop Pizza Place Café Bakery Grocery Store Food & Drink Shop Filipino Restaurant Bar Bank Market
toronto_merged.loc[toronto_merged['Cluster Labels']==3]
Area Neighborhood Area average price 2019 Latitude Longitude Cluster Labels 1st Most Common Venue 2nd Most Common Venue 3rd Most Common Venue 4th Most Common Venue 5th Most Common Venue 6th Most Common Venue 7th Most Common Venue 8th Most Common Venue 9th Most Common Venue 10th Most Common Venue
10 Toronto E10 West Hill 790226.0 43.768914 -79.187291 3 Pizza Place Fast Food Restaurant Pharmacy Greek Restaurant Restaurant Bank Breakfast Spot Medical Center Smoothie Shop Beer Store
17 Toronto E11 Rouge E11 722209.0 43.804930 -79.165837 3 Park Caribbean Restaurant Pharmacy Fast Food Restaurant Falafel Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory
20 Toronto W05 York University Heights 828052.0 43.758781 -79.519434 3 Pizza Place Fast Food Restaurant Grocery Store Coffee Shop Discount Store Caribbean Restaurant Sandwich Place Falafel Restaurant Fried Chicken Joint Beer Store
24 Toronto W05 Humber Summit 828052.0 43.760078 -79.571760 3 Park Bakery Construction & Landscaping Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant Women's Store
26 Toronto E04 Kennedy Park 761729.0 43.724878 -79.253969 3 Fast Food Restaurant Grocery Store Asian Restaurant Chinese Restaurant Women's Store Factory Electronics Store Ethiopian Restaurant Event Space Falafel Restaurant
27 Toronto E11 Malvern 722209.0 43.809196 -79.221701 3 Fast Food Restaurant Pizza Place Pharmacy Convenience Store Restaurant Skating Rink Bubble Tea Shop Park Grocery Store Sandwich Place
28 Toronto W03 Keelesdale-Eglinton West 843633.0 43.690158 -79.474998 3 Discount Store Sandwich Place Caribbean Restaurant Skating Rink Museum Women's Store Electronics Store Ethiopian Restaurant Event Space Factory
32 Toronto W05 Glenfield-Jane Heights 828052.0 43.724373 -79.458398 3 Clothing Store Men's Store American Restaurant Restaurant Dessert Shop Women's Store Sushi Restaurant Fast Food Restaurant Korean Restaurant Furniture / Home Store
40 Toronto E09 Bendale 727426.0 43.753520 -79.255336 3 Dog Run Grocery Store Department Store Fast Food Restaurant Tennis Court Discount Store Women's Store Factory Electronics Store Ethiopian Restaurant
41 Toronto W03 Corso Italia-Davenport 843633.0 43.677954 -79.443083 3 Italian Restaurant Breakfast Spot Sushi Restaurant Coffee Shop Thai Restaurant Mexican Restaurant Pet Store Brazilian Restaurant Lounge Sandwich Place
44 Toronto E06 Oakridge 857438.0 43.697174 -79.274823 3 Convenience Store Park Restaurant Bus Stop Dessert Shop Ice Cream Shop Filipino Restaurant Field Fast Food Restaurant Farmers Market
50 Toronto W05 Black Creek 828052.0 43.695400 -79.485495 3 ATM Pool Coffee Shop Women's Store Farmers Market Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant
52 Toronto E10 Rouge E10 790226.0 43.804930 -79.165837 3 Park Caribbean Restaurant Pharmacy Fast Food Restaurant Falafel Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory
55 Toronto W04 Mount Dennis 850365.0 43.686960 -79.489551 3 Furniture / Home Store Coffee Shop Pizza Place Bus Line Tennis Court Grocery Store Eastern European Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant
60 Toronto E04 Ionview 761729.0 43.735990 -79.276515 3 Metro Station Deli / Bodega Park Farmers Market Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant Fast Food Restaurant
65 Toronto W10 West Humber-Clairville 739999.0 43.723370 -79.597457 3 Sandwich Place Yoga Studio Department Store Restaurant Theme Park Chinese Restaurant Grocery Store Sporting Goods Shop Coffee Shop Video Game Store
68 Toronto E05 Tam O'Shanter-Sullivan 884020.0 43.779883 -79.305538 3 Thai Restaurant Italian Restaurant Noodle House Gas Station Sandwich Place Discount Store Bank Fast Food Restaurant Shopping Mall Farmers Market
72 Toronto E07 Agincourt North 831826.0 43.808038 -79.266439 3 Chinese Restaurant Bank Fast Food Restaurant Japanese Restaurant Beer Store Sporting Goods Shop Fried Chicken Joint Spa Restaurant Bakery
74 Toronto W10 Thistletown-Beaumonde Heights 739999.0 43.743414 -79.568701 3 Park Bakery Skating Rink Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant Women's Store
79 Toronto E10 Centennial Scarborough 790226.0 43.787491 -79.150768 3 Fish & Chips Shop Park Women's Store Falafel Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory Farmers Market
80 Toronto E04 Dorset Park 761729.0 43.752847 -79.282067 3 Coffee Shop Bowling Alley Bakery Chinese Restaurant Beer Store Clothing Store Fast Food Restaurant Electronics Store Indian Restaurant Accessories Store
84 Toronto E09 Woburn 727426.0 43.759824 -79.225291 3 Fast Food Restaurant Discount Store Coffee Shop Pizza Place Gym Bank Sandwich Place Beer Store Big Box Store Toy / Game Store
87 Toronto E07 Milliken 831826.0 43.823174 -79.301763 3 Chinese Restaurant Japanese Restaurant Bakery Asian Restaurant Intersection Bubble Tea Shop Noodle House Food & Drink Shop Bank Snack Place
88 Toronto E05 L'Amoreaux 884020.0 43.799003 -79.305967 3 Chinese Restaurant Caribbean Restaurant Athletics & Sports Shopping Mall Coffee Shop Bus Stop Falafel Restaurant Electronics Store Ethiopian Restaurant Event Space
91 Toronto W04 Maple Leaf 850365.0 43.712277 -79.490198 3 Bakery Basketball Court Women's Store Farmers Market Ethiopian Restaurant Event Space Factory Falafel Restaurant Fast Food Restaurant Food & Drink Shop
92 Toronto E08 Guildwood 808092.0 43.755225 -79.198229 3 Train Station Baseball Field Storage Facility Women's Store Electronics Store Ethiopian Restaurant Event Space Factory Falafel Restaurant Farmers Market
93 Toronto W04 Rustic 850365.0 43.713366 -79.504504 3 Home Service Intersection Fast Food Restaurant Gas Station Coffee Shop Caribbean Restaurant Pizza Place Egyptian Restaurant Fish Market Fish & Chips Shop
121 Toronto W09 Humber Heights 902203.0 43.698179 -79.523277 3 Breakfast Spot Gas Station Pharmacy Skating Rink Fried Chicken Joint Diner Farmers Market Ethiopian Restaurant Event Space Factory
123 Toronto W04 Yorkdale-Glen Park 850365.0 43.703434 -79.452918 3 Mediterranean Restaurant Bank Coffee Shop Paintball Field Clothing Store Print Shop Sandwich Place Fast Food Restaurant Food & Drink Shop Bike Shop
126 Toronto E08 Cliffcrest 808092.0 43.721836 -79.236214 3 Ice Cream Shop Pizza Place Hardware Store Restaurant Eastern European Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space Factory
128 Toronto E08 Scarborough Village 808092.0 43.743742 -79.211632 3 Coffee Shop Supermarket Pub Pharmacy Fast Food Restaurant Chinese Restaurant Gym Egyptian Restaurant Electronics Store Ethiopian Restaurant
129 Toronto E08 Eglinton East 808092.0 43.739465 -79.232100 3 Ice Cream Shop Restaurant Sandwich Place Indian Restaurant Train Station Falafel Restaurant Egyptian Restaurant Electronics Store Ethiopian Restaurant Event Space
130 Toronto E05 Steeles 884020.0 43.816178 -79.314538 3 Playground Dumpling Restaurant Flea Market Fish Market Fish & Chips Shop Filipino Restaurant Field Fast Food Restaurant Farmers Market Falafel Restaurant
131 Toronto W10 Rexdale-Kipling 739999.0 43.722114 -79.572292 3 Pizza Place Fast Food Restaurant Sandwich Place Department Store Fish & Chips Shop Filipino Restaurant Field Fish Market Flea Market Farmers Market
133 Toronto E10 Highland Creek 790226.0 43.790117 -79.173334 3 IT Services Eastern European Restaurant Flower Shop Flea Market Fish Market Fish & Chips Shop Filipino Restaurant Field Fast Food Restaurant Farmers Market
134 Toronto E09 Morningside 727426.0 43.782601 -79.204958 3 Park Coffee Shop Pharmacy Supermarket Convenience Store Sandwich Place Café Mobile Phone Shop Fast Food Restaurant Beer Store
135 Toronto W10 Elms-Old Rexdale 739999.0 43.721770 -79.552173 3 Caribbean Restaurant Bar Mobile Phone Shop African Restaurant Fast Food Restaurant Ethiopian Restaurant Event Space Factory Falafel Restaurant Farmers Market
138 Toronto W04 Weston 850365.0 43.700161 -79.516247 3 Train Station Convenience Store Pharmacy Skating Rink Middle Eastern Restaurant Fried Chicken Joint Laundromat Discount Store Diner Restaurant
toronto_info=toronto_merged.groupby(by='Cluster Labels').mean()
toronto_merged.groupby(by='Cluster Labels').size()
Cluster Labels
0     6
1    38
2    28
3    38
dtype: int64
round(toronto_info['Area average price 2019'])
Cluster Labels
0    2300120.0
1    1166129.0
2    1625880.0
3     805047.0
Name: Area average price 2019, dtype: float64

Conclusion


We have grouped toronto's neighbourhood in 4 clusters.
Here are some results that we found after clustering:

On average cost.

  1. The first cluster's average cost of 2300120.0
  2. The second cluster's average cost of 808301.0
  3. The third cluster's average cost of 1631649.0
  4. The fourth cluster's average cost of 1171028.0

The conclusion would be the first cluster is the most expensive neighbourhood and second is least expensive third and fourth are moderately expensive

The neighborhood is:

  1. First cluster's nearby venues consist of restaurant and grocery shops
  2. Second cluster's nearby venues consist of all types of restaurant and basic amneties. It looks a great neighbourhood to live as the cost is also low
  3. Third Cluster's nearby venues consist of pubs, restaurant, parks, entertainment and leisure places
  4. Fourth Cluster's nearby venues consist of Parks, restaurant, Coffee shops, Banks

The conclusion I got from the above result is the first cluster is the most expensive one. It consist of restaurant and different types of shops and musuem. But this cluster only has six neighborhoods and by analyzing the map we find that it is in the epicentre of the city
The second cluster is the least expensive one and it has restaurant and basic amneties around which could be a great place for people having families By analyzing the map we could know that these neighborhoods surround the epicentre of the city.
The third cluster is all around the city and it is a second most expensive neighborhood. It consist of all the leisure centre and entertainment places hence would be suitable for bachelors. It may also be suitable for opening new stores.
The fourth cluster is away from the epicentre of the city and it also a second least expensive place. It has Parks, restaurant and coffee shops all around it.