This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ~~~~~~~~~~~~~ ## | |
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"), |