library(knitr)See: Data Science Certificate repo https://github.com/DataScienceSpecialization/courses
library(knitr)See: Data Science Certificate repo https://github.com/DataScienceSpecialization/courses
| # #Majority Vote Accuracy | |
| # For Johns Hopkins / Machine Learning in R | |
| # n <- 5 # Independent Classifiers | |
| # k <- 3 # | |
| # | |
| # accuracy <- 0.7 | |
| # | |
| # majorityAccu(5, 3, .7) # 83.7% Accuracy | |
| # majorityAccu(101, 51, .7) #99.9% Accuracy |
| #Search installed packages by first letter -- regardless of upper/lower case (by 's' here) | |
| grep("^[s]", attributes(installed.packages())$dimnames[[1]], value = TRUE, ignore.case = TRUE) |
| # Quick GIST I wrote in the Data Science Capstone JHU forum (Dec 2014) | |
| # It appears if the one of us draws 5 random tweets or news excerpts as the grading criteria calls for, | |
| # the probability that none of the five match the top-word is 32.8%--assuming the | |
| # true accuracy of model is 20%. | |
| # Overall, if the top-word as criteria for success is used, where 4 reviewers using 5 random samples, | |
| # the probability that none of the 20 predictions match the top word is only 1.2%. | |
| stringToChar<- function( example ){ | |
| example <- as.character(example) | |
| letters <- strsplit(example,"")[[1]] | |
| for (i in letters[1:length(letters)] ) { print(i) } | |
| } | |
Sets the working directory in R on a Linux system after and are replaced with actual folder names.
Alows for sharing code without each user having to change the HOME variable (e.g., "home/myMachine/Projects/First"
setwd(paste0(Sys.getenv("HOME"),"/<TopDir>/<Root>")) For Windows, use proper slash direction and notation.