środa, 30 grudnia 2015

Day 2 with R. Ideas for diving in deep waters


Start with example here: https://stat.ethz.ch/R-manual/R-devel/library/class/html/knn.html
Then go through: http://blog.datacamp.com/machine-learning-in-r/
========================
Additional reading:
https://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Classification/kNN
https://www3.nd.edu/~steve/computing_with_data/17_Refining_kNN/refining_knn.html
http://blog.webagesolutions.com/archives/1164
http://www.analyticsvidhya.com/blog/2015/08/learning-concept-knn-algorithms-programming/

K means vs K nearest neighbors are two different things.
https://www.quora.com/Is-the-k-Means-algorithm-related-to-the-k-Nearest-Neighbors-algorithm
https://www.quora.com/How-is-the-k-nearest-neighbor-algorithm-different-from-k-means-clustering

What next:
http://rayli.net/blog/data/top-10-data-mining-algorithms-in-plain-r/

Additional topic:
R and SQL/MS SQL
http://www.burns-stat.com/translating-r-sql-basics/
http://www.r-bloggers.com/make-r-speak-sql-with-sqldf/ - use SQL in R
https://www.simple-talk.com/sql/reporting-services/making-data-analytics-simpler-sql-server-and-r/  make R talk to MS SQL

Ideas for day 3: http://courses.had.co.nz/10-tokyo/
http://www.analyticsvidhya.com/learning-paths-data-science-business-analytics-business-intelligence-big-data/learning-path-r-data-science/

Picturen Lite: best app for viewing lectures on android.

This app appears to be the best choice for viewing video lectures (esp. downloaded khanacademy lessons, R coding lectures) on small devices. One can zoom in to the code being written by the lecturer with fingers. Great. Big thanks to the authors. One fault though (bug? please correct) After pausing and ocking/unlocking the screen it does not remember the last position and starts playing the video from the beginning.

If you know a better one, please let me know.

poniedziałek, 28 grudnia 2015

Day 1 with R

What I have learned today:
> setwd("C:\R")  - set the directory I will put my files,
> getwd() check if it is set correctly

Let's get some data ...

I created a csv file with notepad:
Nazwisko,Wartosc,Wartosc2
Kowalski,23.22,32.12
Nowak,21.21,34.12
Sikorowski,20.2,11.3
Then I read it with R

> b <- read.csv ("test.csv") 

Play with charts:

> plot(b$Wartosc, b$Wartosc2)

> plot(density(b$Wartosc)) - basic density plot

> plot(boxplot(b$Wartosc)) - basic boxplot


Play with k-means clusters
clusters <- kmeans(b[-1],2)

Get data with cluster no. column
 > b <- cbind (b, clusters$cluster)

Plot x y with clusters distinguished by color:
> plot (b$Wartosc, b$Wartosc2, col=b[,3])

To add labels I tried:
> text(b$Wartosc, b$Wartosc2, labels=b$Nazwisko, cex= 0.7, pos=3)

Then I played with http://stats.stackexchange.com/questions/109273/creating-a-cluster-analysis-on-multiple-variables

> numbers_only <- b[c(-1,-4)]
> rownames(numbers_only) <- b$Nazwisko
> d <- dist(numbers_only, method="euclidean")
> fit <- hclust(d, method = "ward.D")
> plot(fit)

What if the tree is too large, and I want to generalize clusters. I need to cut a tree? http://stackoverflow.com/questions/6518133/clustering-list-for-hclust-function

> cutree(fit, h=10)
  Kowalski      Nowak Sikorowski
         1          1          2

Shit, it is 01:00 AM. Good night




Code for Poland

http://kodujdlapolski.pl/projekty/