def create_subplots(images, labels):
plt.subplot()
for _ in range(0, len(images)):
plt.rcParams["figure.figsize"] = [10,20]
plt.subplot(len(images)/2,len(images)/5, _+1)
plt.xticks([]), plt.yticks([])
plt.imshow(npimg, cmap = 'gray')
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 Meeseeks.XPath | |
| HTTPoison.start() | |
| {:ok, response} = HTTPoison.get("feeds.megaphone.fm/tamc1029044713") | |
| doc = Meeseeks.parse(response.body) | |
| [first, second | rest] = Meeseeks.all(doc, xpath("item")) | |
| IO.puts Meeseeks.tree(first) | |
| IO.puts Meeseeks.all(doc, xpath("item//link")) | |
| IO.puts Meeseeks.all(doc, xpath("item//link/text()")) |> Enum.map(&Meeseeks.text/1) |
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
| def timeit(method): | |
| def timing(*args, **kwargs): | |
| timings = [] | |
| print("Running this 1000 loops, for benchmarking") | |
| for i in range(1000): | |
| start = time.time() | |
| result = method(*args, **kwargs) | |
| end = time.time() | |
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
| FROM rocker/r-base | |
| RUN apt-get update && apt-get -y upgrade && apt-get install -y \ | |
| build-essential libssl-dev libffi-dev libxml2-dev libcurl4-openssl-dev | |
| RUN Rscript -e "install.packages(c('caret', 'tidyverse', 'gbm', 'pROC', 'corrplot', 'doParallel', 'dummies', 'futile.logger'), dependencies=TRUE)" | |
| ENV INSTALL_PATH /germancc | |
| RUN mkdir -p $INSTALL_PATH |
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
| FROM rocker/tidyverse | |
| RUN apt-get update && apt-get -y upgrade && apt-get install -y \ | |
| build-essential libssl-dev libffi-dev libxml2-dev libcurl4-openssl-dev | |
| RUN mkdir /home/rstudio/data /home/rstudio/models | |
| VOLUME ['/home/rstudio/data', '/home/rstudio/models'] | |
| RUN Rscript -e "install.packages(c('dummy', 'corrplot', 'pROC'), dependencies=TRUE)" |
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
| #setwd("~/difference-engine/docker-for-data-science-r/") | |
| source("./src/fe-train.R") | |
| set.seed(42) | |
| # Parallelizing the modelling | |
| # NOTE: Try not to use all the cores | |
| doParallel::registerDoParallel(parallel::detectCores() - 2) | |
| # Write the ML Code here |
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
| source("./src/eda.R") | |
| # Importing the intermediate data | |
| flog.info("Loading the intermediate data") | |
| german_credit <- readRDS("./assets/intermediate-files/intermediate_german_data.rds") | |
| german_credit$rating <- ifelse(german_credit$rating == 1, "good", "bad") | |
| # Checking for missing values | |
| # unlist(lapply(german_credit, function(x) sum(is.na(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
| source("./src/load_package.R") | |
| flog.info("Loading the German Credit Card Dataset") | |
| # Load Dataset | |
| german_credit <- read.table("./assets/data/german.data", fileEncoding="UTF-8" , dec = ",") | |
| head(german_credit) | |
| flog.info("Renaming the Columns") | |
| colnames(german_credit) <- c('status', 'duration', 'credit_history', 'purpose', 'credit_amount', 'savings_account', 'employment', 'installment_rate','status_sex', 'guarantors', 'residence', 'property', 'age', 'other_installment', 'housing', 'existing_credits', 'job', 'maintainence_people','telephone', 'foreign', 'rating') |
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
| list.of.packages <- c("ggplot2", "parallel", "tidyverse", "pROC", "caret", "corrplot", "doParallel", "dummies", "futile.logger") | |
| new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] | |
| # Check whether the packages listed are installed or not | |
| # If not then they are installed | |
| if(length(new.packages)) { | |
| print("Installing new packages") | |
| install.packages(new.packages, repos = "http://cran.us.r-project.org") | |
| } |
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
| require(GGally) | |
| lm.plt <- function(data, mapping, ...){ | |
| plt <- ggplot(data = data, mapping = mapping) + | |
| geom_point(shape = 20, alpha = 0.7, color = 'darkseagreen') + | |
| geom_smooth(method=loess, fill="red", color="red") + | |
| geom_smooth(method=lm, fill="blue", color="blue") + | |
| theme_minimal() | |
| return(plt) | |
| } |
NewerOlder