Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 7 additions & 7 deletions configs/bce_category.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'bce-category-embedding-1'
demographics_file: './data/demographicData/csv/data_world/us_city_demographics.csv'
demographics_normalized_file: './data/demographicData/csv/census_est_all_data_2019/county_ethnicity_fractions_2019.csv'
embeddings_file: './data/embeddings/category_bing_embeddings.csv'
name: "bce-category-embedding-1"
demographics_file: "./data/demographicData/csv/data_world/us_city_demographics.csv"
demographics_normalized_file: "./data/demographicData/csv/census_est_all_data_2019/county_ethnicity_fractions_2019.csv"
embeddings_file: "./data/embeddings/name_category_embeddings.csv"
lr: 1e-5
weight_decay: 1e-4 # 1e-5 for MSE, 1e-4 for BCEWithLogits
loss: 'BCEWithLogits' # 'MSE' or 'BCEWithLogits'
restaurant_data_source: 'Bing'
loss: "BCEWithLogits" # 'MSE' or 'BCEWithLogits'
restaurant_data_source: "Bing"
hidden_layer_size: 512
num_epochs: 7000
num_epochs: 7000
10 changes: 10 additions & 0 deletions configs/category-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "pca-category-names-1"
demographics_file: "./data/demographicData/csv/data_world/us_city_demographics.csv"
demographics_normalized_file: "./data/demographicData/csv/census_est_all_data_2019/county_ethnicity_fractions_2019.csv"
embeddings_file: "./data/embeddings/pca_name_category_embeddings.csv"
lr: 1e-5
weight_decay: 1e-5 # 1e-5 for MSE, 1e-4 for BCEWithLogits
loss: "MSE" # 'MSE' or 'BCEWithLogits'
restaurant_data_source: "Bing"
hidden_layer_size: 512
num_epochs: 7000
77 changes: 44 additions & 33 deletions data/bingMaps/bingData.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,47 @@

cuisine = "Restaurants" # define the type of cuisine you're interested in

# read locations from counties_states.csv
with open("edited_counties.csv", "r") as f:
reader = csv.reader(f)
locations = list(islice(reader, 1917, None)) # skip to line 449

# for each location
for location in locations:
location = " ".join(location) # convert list to string

# construct the URL for the HTTP request
url = f"https://atlas.microsoft.com/search/poi/json?subscription-key={api_key}&api-version=1.0&query={cuisine}+in+{location}&limit=100"

response = requests.get(url) # make the HTTP request

data = response.json() # parse the response

# prepare data for CSV
csv_data = []
for item in data.get("results", []):
# categories = item["poi"]["categories"]
name = item["poi"]["name"]
# print(name)
# if "restaurant" in categories: # if "restaurant" is in categories, remove it
# categories.remove("restaurant")
if name: # if not empty
csv_data.append([name])

# write data to CSV file
with open(f"nameCategory/{location}.csv", "w", newline="") as file:
writer = csv.writer(file)
print("Currently creating: ", location)
writer.writerow(["Name"]) # write the header
writer.writerows(csv_data) # write the rows

def fetch_restaurant_data():
"""
Fetches restaurant data from Bing Maps API for different locations and saves it in CSV files.

This function reads locations from a CSV file, constructs the URL for the HTTP request to the Bing Maps API,
makes the request, parses the response, and saves the relevant data in CSV files.

Returns:
None
"""

# read locations from counties_states.csv
with open("edited_counties.csv", "r") as f:
reader = csv.reader(f)
locations = list(islice(reader, 1917, None)) # skip to line 449

# for each location
for location in locations:
location = " ".join(location) # convert list to string

# construct the URL for the HTTP request
url = f"https://atlas.microsoft.com/search/poi/json?subscription-key={api_key}&api-version=1.0&query={cuisine}+in+{location}&limit=100"

response = requests.get(url) # make the HTTP request

data = response.json() # parse the response

# prepare data for CSV
csv_data = []
for item in data.get("results", []):
name = item["poi"]["name"]
if name: # if not empty
csv_data.append([name])

# write data to CSV file
with open(f"name_category/{location}.csv", "w", newline="") as file:
writer = csv.writer(file)
print("Currently creating: ", location)
writer.writerow(["Name"]) # write the header
writer.writerows(csv_data) # write the rows


fetch_restaurant_data()
17 changes: 0 additions & 17 deletions data/bingMaps/editCountiesCsv.py

This file was deleted.

Loading