This file contains hidden or 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
| datatypes <- function(dataframe){ | |
| types <- split(names(dataframe),sapply(dataframe, function(x) paste(class(x), collapse=" "))) | |
| return(types) | |
| } | |
| factor_cols <- c() | |
| raw_data[,factor_cols] <- lapply(raw_data[,factor_cols], | |
| function(x) factor(x)) |
This file contains hidden or 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_metrics <- function(model, test_data, truth, table = FALSE){ | |
| preds <- predict(model, test_data); | |
| table_ <- table(truth, preds); | |
| acc_ <- sum(diag(table_))/sum(table_); | |
| rec_ <- table_[2,2]/sum(table_[,2]); | |
| prec_ <- table_[2,2]/sum(table_[2,]); | |
| f_ <- 2*rec_*prec_/(rec_+prec_) | |
| if (table == FALSE){ | |
| cat('Accuracy:', acc_, '\nRecall:', rec_, '\nPrecision:', prec_, '\nF-Score:', f_); | |
| } else { |
This file contains hidden or 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
| test_train_split <- function(data, train_frac = 0.66){ | |
| library(caret) | |
| inTrain <- createDataPartition(1:nrow(data), p = train_frac, list = FALSE) | |
| training <- data[inTrain,] | |
| testing <- data[-inTrain,] | |
| return(list(train = training, test = testing)) | |
| } |
This file contains hidden or 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
| ## arrow up | |
| "\e[A":history-search-backward | |
| ## arrow down | |
| "\e[B":history-search-forward |
This file contains hidden or 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 matplotlib.pyplot as plt | |
| plt.rcParams['figure.figsize'] = 5, 10 | |
| %matplotlib inline |
This file contains hidden or 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
| ######################################## | |
| '''Simple Bar Chart''' | |
| x_axis=['a','b','c'] | |
| y_axis=[10,12,11] | |
| fig, ax = plt.subplots(figsize=(20, 8)) | |
| ax.set_xticks(range(len(x_axis))) | |
| ax.bar(range(len(x_axis)), y_axis, align='center') | |
| ax.set_xticklabels(x_axis, rotation='vertical') |
This file contains hidden or 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
| map h :help | |
| let mapleader = ',' | |
| let blacklists = ["https://vim-adventures.com/*","http://localhost/*","https://youtube.com/*","http://www.kongregate.com/*"] | |
| map <Leader>e :tabopen chrome://extensions<CR> | |
| map <Leader>E :tabopen https://chrome.google.com/webstore/category/extensions?hl=en<CR> | |
| map <Leader>H :tabopen chrome://history<CR> | |
| map <Leader>gg :tabopen https://gist.github.com/sizhky/6ce05580f394742fcd45c4bf1f5c18d6<CR> | |
| map <Leader>s :tabopen chrome://settings<CR> | |
| " let searchalias g = "google" | |
| map <Leader>m :tabopen https://mail.google.com/mail/#index<CR> |
This file contains hidden or 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
| set number |
This file contains hidden or 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
| .container { width:97.5% !important; } | |
| ~/.jupyter/custom/custom.css | |
| https://stackoverflow.com/questions/21971449/how-do-i-increase-the-cell-width-of-the-jupyter-ipython-notebook-in-my-browser |
This file contains hidden or 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
| trace(utils:::unpackPkgZip, edit=TRUE) |
OlderNewer