Skip to content

Instantly share code, notes, and snippets.

from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
"""
Use your classification model to predict some labels
Then, plot confusion matrix and classification report using below code
y_test: real labels
y_pred: predicted model labels
@Francismorales
Francismorales / Google_PlacesAPI_address_search.py
Created May 19, 2020 04:23
This routine takes the street name and number of McDonalds restaurants and returns the full formatted address (zip code included) and the permanently closed variable from Google Maps Places API.
import pandas as pd
import requests
import json
addres_list = list(McDonalds_data['address']) #prepare variable to pass to URL
state_list = list(McDonalds_data['state']) #prepare variable to pass to URL
placesAPI_data = pd.DataFrame(columns=['formatted_address', 'name', 'permanently_closed']) #initialize dataframe
for i in range(len(addres_list)):
address = addres_list[i].replace(' ', '%20') #make sure there are no blank spaces for the URL
state = state_list[i]
@Francismorales
Francismorales / Web_scraping_McDonalds.py
Last active February 10, 2025 10:23
This is a routine for web scraping McDonald's restaurants' addresses by zip code. Web page: Menuism.com
from bs4 import BeautifulSoup
import urllib.request
import pandas as pd
import time
import random
scrapping_list = web_scrapping_list[0:2000] #this is your list of zip codes
alldata = pd.DataFrame(columns=['name', 'address', 'city', 'zipcode']) #initialize dataframe
for j, zipi in enumerate(scrapping_list):
url = "https://www.menuism.com/search?q=McDonald%27s&l=" + zipi + "&p=0&s=match&pp=25&f=0"