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
| # Enable tab completion | |
| source ~/git-completion.bash | |
| # colors! | |
| green="\[\033[0;32m\]" | |
| blue="\[\033[0;34m\]" | |
| purple="\[\033[0;35m\]" | |
| reset="\[\033[0m\]" | |
| # Change command prompt |
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
| # bash/zsh completion support for core Git. | |
| # | |
| # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
| # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
| # Distributed under the GNU General Public License, version 2.0. | |
| # | |
| # The contained completion routines provide support for completing: | |
| # | |
| # *) local and remote branch names | |
| # *) local and remote tag names |
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
| # bash/zsh git prompt support | |
| # | |
| # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
| # Distributed under the GNU General Public License, version 2.0. | |
| # | |
| # This script allows you to see repository status in your prompt. | |
| # | |
| # To enable: | |
| # | |
| # 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). |
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
| # tabtab source for serverless package | |
| # uninstall by removing these lines or running `tabtab uninstall serverless` | |
| [ -f /Users/salma_elshahawy/Desktop/emicredit/node_modules/tabtab/.completions/serverless.bash ] && . /Users/salma_elshahawy/Desktop/emicredit/node_modules/tabtab/.completions/serverless.bash | |
| # tabtab source for sls package | |
| # uninstall by removing these lines or running `tabtab uninstall sls` | |
| [ -f /Users/salma_elshahawy/Desktop/emicredit/node_modules/tabtab/.completions/sls.bash ] && . /Users/salma_elshahawy/Desktop/emicredit/node_modules/tabtab/.completions/sls.bash |
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
| # loading the required libraries | |
| library(tidyverse) | |
| library(dplyr) | |
| library(ggplot) | |
| library(readr) | |
| library(caret) | |
| # import train to R | |
| train_df <- read.csv("train.csv", stringsAsFactors = FALSE) | |
| head(train_df) |
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
| # Impute missing ages in Training data using caret | |
| # picking only Age | |
| train_df %>% select(-Ticket, -Name, -Cabin, -Embarked) -> train_ages | |
| # use method bagImpute | |
| pre_proc <- preProcess(train_ages, method = "bagImpute") | |
| # predict Age | |
| train_ages <- predict(pre_proc, train_ages) | |
| # Append predicted age into train_df | |
| train_df$Age <- train_ages$Age |
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
| PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | S | ||
| 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C | |
| 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | S | ||
| 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S | |
| 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | S | ||
| 6 | 0 | 3 | Moran, Mr. James | male | 0 | 0 | 330877 | 8.4583 | Q | |||
| 7 | 0 | 1 | McCarthy, Mr. Timothy J | male | 54 | 0 | 0 | 17463 | 51.8625 | E46 | S | |
| 8 | 0 | 3 | Palsson, Master. Gosta Leonard | male | 2 | 3 | 1 | 349909 | 21.075 | S | ||
| 9 | 1 | 3 | Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) | female | 27 | 0 | 2 | 347742 | 11.1333 | S |
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
| # clean up NAs | |
| sapply(train_df, function(x) sum(is.na(x))) | |
| # PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Fare | |
| # 0 0 0 0 0 177 0 0 0 0 | |
| # Cabin Embarked | |
| # 0 0 |
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
| ggplot(train_df, mapping = aes(x = Survived, y = Age, fill = Survived)) + | |
| geom_boxplot(outlier.colour = "red", outlier.shape = 5, outlier.size = 4) + | |
| facet_wrap(~Sex) | |
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
| # outlier detection and normalizing | |
| outlier_norm <- function(x){ | |
| qntile <- quantile(x, probs=c(.25, .75)) | |
| caps <- quantile(x, probs=c(.05, .95)) | |
| H <- 1.5 * IQR(x, na.rm = T) | |
| x[x < (qntile[1] - H)] <- caps[1] | |
| x[x > (qntile[2] + H)] <- caps[2] | |
| return(x) | |
| } | |
| train_df$Age=outlier_norm(train_df$Age) |