{ "cells": [ { "cell_type": "code", "execution_count": 248, "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2023-11-06T00:18:48.861074Z", "start_time": "2023-11-06T00:18:48.853531Z" } }, "outputs": [], "source": [ "import folium\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "from scipy.cluster.hierarchy import dendrogram, linkage\n", "from scipy.cluster.hierarchy import fcluster\n", "from sklearn.metrics import silhouette_score\n", "from sklearn.cluster import KMeans\n", "import utils" ] }, { "cell_type": "code", "execution_count": 249, "outputs": [], "source": [ "# Load the data\n", "ListA = pd.read_csv('List A.csv')\n", "ListB = pd.read_csv('List B.csv')\n", "ListC = pd.read_csv('List C.csv')\n", "ListD = pd.read_csv('List D.csv')" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2023-11-06T00:18:49.113478Z", "start_time": "2023-11-06T00:18:49.101708Z" } }, "id": "bb6f57eef695cf76" }, { "cell_type": "code", "execution_count": 250, "outputs": [ { "data": { "text/plain": " name gps \\\n0 521 Commercial Street #525 42.3688272,-71.0553792 \n1 Acorn St 42.3576234,-71.0688746 \n2 Arlington's Great Meadows 42.4299758,-71.2038948 \n3 Arthur Fiedler Statue 42.3565057,-71.0754527 \n4 BU Beach 42.3511927,-71.1060828 \n.. ... ... \n33 The Quiet Few 42.3670906,-71.0359889 \n34 The Tall Ship Boston 42.3649544,-71.0414523 \n35 Toasted Flats 42.3711266,-71.0371343 \n36 Vega Market 42.3891835,-71.033703 \n37 Winthrop High School 42.3803348,-70.9799864 \n\n googleUrl \\\n0 https://maps.google.com/maps?q=+%4042.3688272,... \n1 https://maps.google.com/maps?q=+%4042.3576234,... \n2 https://maps.google.com/maps?q=+%4042.4299758,... \n3 https://maps.google.com/maps?q=+%4042.3565057,... \n4 https://maps.google.com/maps?q=+%4042.3511927,... \n.. ... \n33 https://maps.google.com/maps?q=+%4042.3670906,... \n34 https://maps.google.com/maps?q=+%4042.3649544,... \n35 https://maps.google.com/maps?q=+%4042.3711266,... \n36 https://maps.google.com/maps?q=+%4042.3891835,... \n37 https://maps.google.com/maps?q=+%4042.3803348,... \n\n originalUrl info types \\\n0 https://www.google.com/maps/place/521+Commerci... NaN NaN \n1 https://www.google.com/maps/place/Acorn+St/dat... NaN NaN \n2 https://www.google.com/maps/place/Arlington's+... NaN NaN \n3 https://www.google.com/maps/place/Arthur+Fiedl... NaN NaN \n4 https://www.google.com/maps/place/BU+Beach/dat... NaN NaN \n.. ... ... ... \n33 https://www.google.com/maps/place/The+Quiet+Fe... NaN NaN \n34 https://www.google.com/maps/place/The+Tall+Shi... NaN NaN \n35 https://www.google.com/maps/place/Toasted+Flat... NaN NaN \n36 https://www.google.com/maps/place/Vega+Market/... NaN NaN \n37 https://www.google.com/maps/place/Winthrop+Hig... NaN NaN \n\n address \\\n0 NaN \n1 NaN \n2 Minuteman Commuter Bikeway, Lexington, MA 0242... \n3 Charles River Esplanades, Boston, MA 02114, Un... \n4 270 Bay State Rd, Boston, MA 02215, United States \n.. ... \n33 331 Sumner St, East Boston, MA 02128, United S... \n34 1 E Pier Dr, Boston, MA 02128, United States \n35 53 Chelsea St, Boston, MA 02128, United States \n36 29 Maverick St, Chelsea, MA 02150, United States \n37 400 Main St, Winthrop, MA 02152, United States \n\n description type \\\n0 NaN NaN \n1 NaN NaN \n2 183-acres of wet meadows & uplands with trails... Nature preserve \n3 NaN Sculpture \n4 A sloping, grassy plaza on the university grou... Park \n.. ... ... \n33 NaN Bar \n34 Laid-back waterside tall ship with tables doli... Lounge \n35 Snug eatery whipping up health-conscious flatb... Sandwich shop \n36 NaN Grocery store \n37 NaN High school \n\n phone website \\\n0 NaN NaN \n1 NaN NaN \n2 +1 781-863-5385 http://www.foagm.org/ \n3 +1 617-332-2433 http://helmicksculpture.com/portfolio/arthur-f... \n4 NaN https://www.bu.edu/today/2009/icons-among-us-t... \n.. ... ... \n33 +1 617-561-1061 https://www.thequietfew.com/ \n34 +1 617-307-7714 https://www.tallshipboston.com/ \n35 +1 857-264-8531 https://toastedflats.com/ \n36 NaN NaN \n37 +1 617-846-5505 https://www.winthrop.k12.ma.us/Domain/99 \n\n ratingsAverage ratingsTotal plusCode list \n0 NaN NaN NaN A \n1 NaN NaN NaN A \n2 4.6 171.0 CQHW+XC Lexington, Massachusetts, USA A \n3 4.6 14.0 9W4F+JR Boston, Massachusetts, USA A \n4 4.5 133.0 9V2V+FH Boston, Massachusetts, USA A \n.. ... ... ... ... \n33 4.7 257.0 9X87+RJ East Boston, Boston, MA, USA D \n34 4.2 549.0 9X75+XC Boston, Massachusetts, USA D \n35 4.7 372.0 9XC7+F4 Boston, Massachusetts, USA D \n36 4.8 5.0 9XQ8+MG Chelsea, Massachusetts, USA D \n37 NaN NaN 92JC+42 Winthrop, Massachusetts, USA D \n\n[169 rows x 15 columns]", "text/html": "
| \n | name | \ngps | \ngoogleUrl | \noriginalUrl | \ninfo | \ntypes | \naddress | \ndescription | \ntype | \nphone | \nwebsite | \nratingsAverage | \nratingsTotal | \nplusCode | \nlist | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n521 Commercial Street #525 | \n42.3688272,-71.0553792 | \nhttps://maps.google.com/maps?q=+%4042.3688272,... | \nhttps://www.google.com/maps/place/521+Commerci... | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nA | \n
| 1 | \nAcorn St | \n42.3576234,-71.0688746 | \nhttps://maps.google.com/maps?q=+%4042.3576234,... | \nhttps://www.google.com/maps/place/Acorn+St/dat... | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nNaN | \nA | \n
| 2 | \nArlington's Great Meadows | \n42.4299758,-71.2038948 | \nhttps://maps.google.com/maps?q=+%4042.4299758,... | \nhttps://www.google.com/maps/place/Arlington's+... | \nNaN | \nNaN | \nMinuteman Commuter Bikeway, Lexington, MA 0242... | \n183-acres of wet meadows & uplands with trails... | \nNature preserve | \n+1 781-863-5385 | \nhttp://www.foagm.org/ | \n4.6 | \n171.0 | \nCQHW+XC Lexington, Massachusetts, USA | \nA | \n
| 3 | \nArthur Fiedler Statue | \n42.3565057,-71.0754527 | \nhttps://maps.google.com/maps?q=+%4042.3565057,... | \nhttps://www.google.com/maps/place/Arthur+Fiedl... | \nNaN | \nNaN | \nCharles River Esplanades, Boston, MA 02114, Un... | \nNaN | \nSculpture | \n+1 617-332-2433 | \nhttp://helmicksculpture.com/portfolio/arthur-f... | \n4.6 | \n14.0 | \n9W4F+JR Boston, Massachusetts, USA | \nA | \n
| 4 | \nBU Beach | \n42.3511927,-71.1060828 | \nhttps://maps.google.com/maps?q=+%4042.3511927,... | \nhttps://www.google.com/maps/place/BU+Beach/dat... | \nNaN | \nNaN | \n270 Bay State Rd, Boston, MA 02215, United States | \nA sloping, grassy plaza on the university grou... | \nPark | \nNaN | \nhttps://www.bu.edu/today/2009/icons-among-us-t... | \n4.5 | \n133.0 | \n9V2V+FH Boston, Massachusetts, USA | \nA | \n
| ... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n
| 33 | \nThe Quiet Few | \n42.3670906,-71.0359889 | \nhttps://maps.google.com/maps?q=+%4042.3670906,... | \nhttps://www.google.com/maps/place/The+Quiet+Fe... | \nNaN | \nNaN | \n331 Sumner St, East Boston, MA 02128, United S... | \nNaN | \nBar | \n+1 617-561-1061 | \nhttps://www.thequietfew.com/ | \n4.7 | \n257.0 | \n9X87+RJ East Boston, Boston, MA, USA | \nD | \n
| 34 | \nThe Tall Ship Boston | \n42.3649544,-71.0414523 | \nhttps://maps.google.com/maps?q=+%4042.3649544,... | \nhttps://www.google.com/maps/place/The+Tall+Shi... | \nNaN | \nNaN | \n1 E Pier Dr, Boston, MA 02128, United States | \nLaid-back waterside tall ship with tables doli... | \nLounge | \n+1 617-307-7714 | \nhttps://www.tallshipboston.com/ | \n4.2 | \n549.0 | \n9X75+XC Boston, Massachusetts, USA | \nD | \n
| 35 | \nToasted Flats | \n42.3711266,-71.0371343 | \nhttps://maps.google.com/maps?q=+%4042.3711266,... | \nhttps://www.google.com/maps/place/Toasted+Flat... | \nNaN | \nNaN | \n53 Chelsea St, Boston, MA 02128, United States | \nSnug eatery whipping up health-conscious flatb... | \nSandwich shop | \n+1 857-264-8531 | \nhttps://toastedflats.com/ | \n4.7 | \n372.0 | \n9XC7+F4 Boston, Massachusetts, USA | \nD | \n
| 36 | \nVega Market | \n42.3891835,-71.033703 | \nhttps://maps.google.com/maps?q=+%4042.3891835,... | \nhttps://www.google.com/maps/place/Vega+Market/... | \nNaN | \nNaN | \n29 Maverick St, Chelsea, MA 02150, United States | \nNaN | \nGrocery store | \nNaN | \nNaN | \n4.8 | \n5.0 | \n9XQ8+MG Chelsea, Massachusetts, USA | \nD | \n
| 37 | \nWinthrop High School | \n42.3803348,-70.9799864 | \nhttps://maps.google.com/maps?q=+%4042.3803348,... | \nhttps://www.google.com/maps/place/Winthrop+Hig... | \nNaN | \nNaN | \n400 Main St, Winthrop, MA 02152, United States | \nNaN | \nHigh school | \n+1 617-846-5505 | \nhttps://www.winthrop.k12.ma.us/Domain/99 | \nNaN | \nNaN | \n92JC+42 Winthrop, Massachusetts, USA | \nD | \n
169 rows × 15 columns
\n| \n | name | \ngps | \nlist | \n
|---|---|---|---|
| 0 | \n521 Commercial Street #525 | \n[42.3688272, -71.0553792] | \nA | \n
| 1 | \nAcorn St | \n[42.3576234, -71.0688746] | \nA | \n
| 2 | \nArlington's Great Meadows | \n[42.4299758, -71.2038948] | \nA | \n
| 3 | \nArthur Fiedler Statue | \n[42.3565057, -71.0754527] | \nA | \n
| 4 | \nBU Beach | \n[42.3511927, -71.1060828] | \nA | \n
| ... | \n... | \n... | \n... | \n
| 33 | \nThe Quiet Few | \n[42.3670906, -71.0359889] | \nD | \n
| 34 | \nThe Tall Ship Boston | \n[42.3649544, -71.0414523] | \nD | \n
| 35 | \nToasted Flats | \n[42.3711266, -71.0371343] | \nD | \n
| 36 | \nVega Market | \n[42.3891835, -71.033703] | \nD | \n
| 37 | \nWinthrop High School | \n[42.3803348, -70.9799864] | \nD | \n
169 rows × 3 columns
\n| \n | name | \ngps | \nlist | \nweights | \n
|---|---|---|---|---|
| 0 | \n521 Commercial Street #525 | \n[42.3688272, -71.0553792] | \nA | \n0.016268 | \n
| 1 | \nAcorn St | \n[42.3576234, -71.0688746] | \nA | \n0.007206 | \n
| 2 | \nArlington's Great Meadows | \n[42.4299758, -71.2038948] | \nA | \n0.000607 | \n
| 3 | \nArthur Fiedler Statue | \n[42.3565057, -71.0754527] | \nA | \n0.004854 | \n
| 4 | \nBU Beach | \n[42.3511927, -71.1060828] | \nA | \n0.001925 | \n
| ... | \n... | \n... | \n... | \n... | \n
| 33 | \nThe Quiet Few | \n[42.3670906, -71.0359889] | \nD | \n0.004835 | \n
| 34 | \nThe Tall Ship Boston | \n[42.3649544, -71.0414523] | \nD | \n0.006736 | \n
| 35 | \nToasted Flats | \n[42.3711266, -71.0371343] | \nD | \n0.004775 | \n
| 36 | \nVega Market | \n[42.3891835, -71.033703] | \nD | \n0.002828 | \n
| 37 | \nWinthrop High School | \n[42.3803348, -70.9799864] | \nD | \n0.001269 | \n
169 rows × 4 columns
\n| \n | name | \ngps | \nlist | \nweights | \ncluster | \n
|---|---|---|---|---|---|
| 0 | \n521 Commercial Street #525 | \n[42.3688272, -71.0553792] | \nA | \n0.016268 | \n0 | \n
| 1 | \nAcorn St | \n[42.3576234, -71.0688746] | \nA | \n0.007206 | \n0 | \n
| 2 | \nArlington's Great Meadows | \n[42.4299758, -71.2038948] | \nA | \n0.000607 | \n1 | \n
| 3 | \nArthur Fiedler Statue | \n[42.3565057, -71.0754527] | \nA | \n0.004854 | \n0 | \n
| 4 | \nBU Beach | \n[42.3511927, -71.1060828] | \nA | \n0.001925 | \n1 | \n
| ... | \n... | \n... | \n... | \n... | \n... | \n
| 33 | \nThe Quiet Few | \n[42.3670906, -71.0359889] | \nD | \n0.004835 | \n0 | \n
| 34 | \nThe Tall Ship Boston | \n[42.3649544, -71.0414523] | \nD | \n0.006736 | \n0 | \n
| 35 | \nToasted Flats | \n[42.3711266, -71.0371343] | \nD | \n0.004775 | \n0 | \n
| 36 | \nVega Market | \n[42.3891835, -71.033703] | \nD | \n0.002828 | \n0 | \n
| 37 | \nWinthrop High School | \n[42.3803348, -70.9799864] | \nD | \n0.001269 | \n0 | \n
169 rows × 5 columns
\n