Skip to content

Instantly share code, notes, and snippets.

View annecool37's full-sized avatar

Anne Chen annecool37

View GitHub Profile
@annecool37
annecool37 / 1_recommendation.R
Last active September 22, 2016 22:22
museo_shiny_server
# get the recommendation if the recommendation button is hit
museumInput = eventReactive(input$recommend_btn,{
# get museum names and concatenate by ';'
museum_names = ""
for (m in input$selected_museum){
museum_names = paste(museum_names, m, sep = ';')
}
# pass the selected museum names into python to compute consine similarity
command_line = paste0('python get_sorted_suggestion.py "', museum_names, '"')
system(command_line)
@annecool37
annecool37 / 1_web_scraping_example.py
Last active January 4, 2021 12:12
Museum_recommendation_system
# This section demonstrates:
# 1. How I got address of the museum
# 2. How I convert adress into latitude and longitude via Google API
# 3. The main code to scrape the data and save it into .csv
from bs4 import BeautifulSoup
import pandas as pd
import googlemaps
def get_address(museum_soup):
@annecool37
annecool37 / random_forest.R
Last active August 20, 2016 19:12
meetup_analysis
## ~~~~~~~~~~~~~ ##
## Random Forest ##
## ~~~~~~~~~~~~~ ##
set.seed(8)
# subset training and testing datasets
train_idx = sample(1:nrow(rf_model_df), 8*nrow(rf_model_df)/10)
tree_train = rf_model_df[train_idx,]
tree_test = rf_model_df[-train_idx,]
# find the best mtry
@annecool37
annecool37 / meetup_web_scraping.py
Last active August 20, 2016 19:31
meetup_web_scraping
### Workflow Example:
### 1. Create master meetup soup
### 2. Convert all event url into beautiful soup objects
### 3. Extract number of participants for an event
# 1.
# Pass in the search result url listing events in that area
# Click the "Show More" button and scroll down the page till a pre-specified time show up
# Convert the whole page into a Beautifulsoup object
def get_meet_up_soup(url, to_which_date):
@annecool37
annecool37 / line_chart_server.R
Last active August 5, 2016 01:24
A glance at the code of Global Coffee Trade
# This part of the code shows how I create the line chart in the "Trend" tab
# Packages used: dplyr, shiny, shinydashboard, googleVis
# Overview:
# 1. create reactive object to read input from the ui function
# 2. render chart
# line chart (time series) to see how attributes change over time for a particular country
coffee_over_time = reactive({
# validate if user select the desired input
validate(
need(input$checked != "", "Please check at least one variable in category"),