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
# ipak function: install and load multiple R packages. | |
# check to see if packages are installed. Install them if they are not, then load them into the R session. | |
ipak <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg)) | |
install.packages(new.pkg, dependencies = TRUE) | |
sapply(pkg, require, character.only = TRUE) | |
} |
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
#Linlin Cheng | |
#Proj 5. tuning file1 | |
library(caret) | |
library(xgboost) | |
library(readr) | |
library(dplyr) | |
library(tidyr) | |
######################## |
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
#Linlin Cheng | |
#Proj.5 Main Script | |
#09/21/2016 | |
#loading packages: | |
library(dplyr) | |
library(VIM) | |
library(ggplot2) | |
library(ggmap) | |
library(glmnet) |
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
#Step 4. Create the item info file: | |
import itertools | |
merged_item_list = list(itertools.chain(*item_url_list)) | |
driver = webdriver.Chrome() | |
final_item_result_list = [] | |
for url in merged_item_list: | |
try: |
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
#save new_list, a list of dictionaries to a csv file: | |
keys = tmp_list[0].keys() | |
with open("event_list.csv", "w") as f: | |
dict_writer = DictWriter(f, keys, delimiter=",") | |
dict_writer.writeheader() | |
for value in tmp_list: | |
dict_writer.writerow(value) |
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
import urllib2 | |
from bs4 import BeautifulSoup | |
import requests | |
import re | |
import urlparse | |
from selenium import webdriver | |
from csv import DictWriter | |
import json | |