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
rfGrid = expand.grid(mtry = c(2,16,30)) | |
m_rf = train(x=train_repNA, y=labels, method="rf", weights=weight, verbose=TRUE, | |
trControl=ctrl, metric="AMS") | |
m_rf$finalModel | |
rfTestPred = predict(m_rf, newdata=test_repNA, type="prob") | |
predicted = rep("b",550000) | |
predicted[rfTestPred[,2]>=threshold] = "s" | |
weightRank = rank(rfTestPred[,2], ties.method= "random") |
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
michelin_rest_scrape = [] | |
michelin_rev_scrape = [] | |
michelin_rest_scrape.append(url_cycle(m_url[0:])) | |
michelin_rev_scrape.append(url_cycle(m_url[0:])) | |
pd.DataFrame(michelin_rest_scrape[0]).to_csv('michelin_restaurant_data.csv', header = True) | |
flattened_list = [] | |
for x in michelin_rev_scrape: |
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
t.test(t.gain.elite_ann_chg, t.none.elite_ann_chg, alternative = "greater") | |
Welch Two Sample t-test | |
data: t.gain.elite_ann_chg and t.none.elite_ann_chg | |
t = 2.6138, df = 48.33, p-value = 0.005952 | |
alternative hypothesis: true difference in means is greater than 0 | |
95 percent confidence interval: | |
0.3561711 Inf | |
sample estimates: |
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
# create summary rows for all reds, all whites, and all districts, and by varietal | |
summary_1 = agro %>% group_by(year, type, reporting_district) %>% summarise(total_tons_crushed = sum(tons_crushed, na.rm = TRUE), total_tons_purchased = sum(tons_purchased, na.rm = TRUE)) | |
summary_2 = agro %>% group_by(year, type) %>% summarise(total_tons_crushed = sum(tons_crushed, na.rm = TRUE), total_tons_purchased = sum(tons_purchased, na.rm = TRUE)) | |
summary_3 = agro %>% group_by(year, type, varietal) %>% summarise(total_tons_crushed = sum(tons_crushed, na.rm = TRUE), total_tons_purchased = sum(tons_purchased, na.rm = 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
import requests | |
import json | |
import time | |
def getdata(offset_no, t = []): | |
r1 = np.arange(1,96000,500) | |
r2 = np.array([0]) | |
r = np.concatenate([r2,r1[1:len(r1)]]) | |
i = offset_no | |
for i in r[r>=offset_no]: | |
try: |