One of the best post for studying machine learning with R
This is definitely one of the best link to learn about machine learning using R.
Although you can follow through the blog, there are some R syntax that you might not be so familiar with :-
a) What is the purpose of this command line
names(iris) <- c="" code="" epal.length="" epal.width="" etal.length="" etal.width="" pecies="">->
This is just for naming your dataset. For example, lets create a list of bird and their size
bird <- bird1="1," bird2="5)</p" list="">
Size 1, would probably be sparrow and size 5 would be a larger bird call eagle. Let change this, using names
names(bird)[1] <- p="" sparrow="">names(bird)[2] <- eagle="" nbsp="" p="">
Output
> bird
$sparrow
[1] 1
$eagle
[1] 5
b) Funny looking operator "%>%"
This is a pipe operator import from magrittr. which is basically allow us to invoke command in sequence.
iris %>% ggvis(~Sepal.Length, ~Sepal.Width, fill = ~Species) %>% layer_points()
This is the same as calling
ggvis(~Sepal.Length, ~Sepal.Width, fill = ~Species)
then
layer_points()
c) Another important aspect in the tutorial is that we divide our dataset into training and test using a sample command.
ind <- 0.33="" code="" iris="" nrow="" prob="c(0.67," replace="TRUE," sample="">->
iris.training <- 1:4="" code="" ind="=2," iris.test="" iris="">->
Notice that knn function requires this input parameters.
knn(train, test, cl, k = 1, l = 0, prob = FALSE, use.all = TRUE)
Some description of the parameters required.
train = input for our training set
test = input for our training set
cl = factor for true classification for training set
k = neighbor considered We have 3 distinct neighbour for our dataset.
Other side notes.
How to install R package
install.packages("")
Check if you have a package installed
any(grepl("", installed.packages()))
->->->
Comments