|
1 | 1 | }
|
2 |
| -} |
3 |
| -for(r in regressor$coefficients) |
4 |
| -{ |
5 |
| -print(r) |
6 |
| -else{ |
7 |
| -print(regressor$coefficients) |
8 |
| -} |
9 |
| -} |
10 |
| -for(r in regressor$coefficients) |
11 |
| -{ |
12 |
| -print(r) |
13 |
| -} |
14 |
| -summary(regressor) |
15 |
| -for(r in regressor$coefficients) |
16 |
| -{ |
17 |
| -print(r[2]) |
18 |
| -} |
19 | 2 | for(r in regressor$coefficients)
|
20 | 3 | {
|
21 | 4 | print(r[3])
|
@@ -493,20 +476,37 @@ SL = 0.05
|
493 | 476 | dataset = dataset[, c(1,2,3,4,5)]
|
494 | 477 | backwardElimination(training_set, SL)
|
495 | 478 | setwd("~/Desktop/Machine_Learning_Algorithms_R/Part 4 - Clustering/Section 25 - Hierarchical Clustering")
|
| 479 | +library(cluster) |
| 480 | +clusplot (dataset, |
| 481 | +y_hc, |
| 482 | +lines = 0, |
| 483 | +shade = TRUE, |
| 484 | +color = TRUE, |
| 485 | +labels = 2, |
| 486 | +plotchar = FALSE, |
| 487 | +span = TRUE, |
| 488 | +main = paste('Clusters of customers'), |
| 489 | +xlab = "Annual Income", |
| 490 | +ylab = "Spending Score") |
496 | 491 | dataset = read.csv("Mall_Customers.csv")
|
497 |
| -dataset = read.csv("Mall_Customers.csv") |
498 |
| -View(dataset) |
499 | 492 | dataset = dataset[4:5]
|
500 |
| -View(dataset) |
501 | 493 | dendrogram = hclust(d = dist(dataset,method = "euclidean"),
|
502 | 494 | method = "ward.D")
|
503 |
| -View(dataset) |
504 | 495 | plot(dendrogram,
|
505 | 496 | main = paste("Dendrogram"),
|
506 | 497 | xlab = "Customers",
|
507 | 498 | ylab = "Euclidean distances")
|
508 | 499 | hc = hclust(d = dist(dataset,method = "euclidean"),
|
509 | 500 | method = "ward.D")
|
510 |
| -y_hc = cutree(ttree = hc, k = 5) |
511 | 501 | y_hc = cutree(tree = hc, k = 5)
|
512 |
| -y_hc |
| 502 | +clusplot (dataset, |
| 503 | +y_hc, |
| 504 | +lines = 0, |
| 505 | +shade = TRUE, |
| 506 | +color = TRUE, |
| 507 | +labels = 2, |
| 508 | +plotchar = FALSE, |
| 509 | +span = TRUE, |
| 510 | +main = paste('Clusters of customers'), |
| 511 | +xlab = "Annual Income", |
| 512 | +ylab = "Spending Score") |
0 commit comments