Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #thingey.csv
- data = read.csv('thingey.csv')
- newdata = data[,-1]
- newdata = na.omit(newdata)
- model = kmeans(newdata, 3)
- plot(newdata, col=model$cluster)
- cluster = model$cluster
- data = cbind(data, cluster)
- write.csv(data, "output.csv")
- #roll no.csv in google classroom
- data = read.csv('dataset.csv')
- newdata = data[,-1]
- newdata = na.omit(newdata)
- model = kmeans(newdata, 5)
- cluster = model$cluster
- data = cbind(data, cluster)
- write.csv(data, "output.csv")
- #iris dataset
- data = iris
- newdata = data[,-5]
- newdata = na.omit(newdata)
- model = kmeans(newdata, 3)
- cluster = model$cluster
- data = cbind(data, cluster)
- clusters = data[6]
- plotdata = data[,-c(2,4,5,6)]
- plot(plotdata, col=cluster)
- #write.csv(copy, "output.csv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement