# DAL ToolBox
# version 1.01.727
source("https://raw.githubusercontent.com/cefet-rj-dal/daltoolbox/main/jupyter.R")
#loading DAL
load_library("daltoolbox")
Loading required package: daltoolbox Registered S3 method overwritten by 'quantmod': method from as.zoo.data.frame zoo Attaching package: ‘daltoolbox’ The following object is masked from ‘package:base’: transform
#load dataset
data(iris)
# setup clustering
model <- cluster_kmeans(k=3)
# build model
model <- fit(model, iris[,1:4])
clu <- cluster(model, iris[,1:4])
table(clu)
clu 1 2 3 96 21 33
# evaluate model using external metric
eval <- evaluate(model, clu, iris$Species)
eval
x | ce | qtd | ceg |
---|---|---|---|
<fct> | <dbl> | <int> | <dbl> |
1 | 0.9987473 | 96 | 0.63919827 |
2 | 0.7024666 | 21 | 0.09834532 |
3 | 0.0000000 | 33 | 0.00000000 |
iris_minmax <- transform(fit(minmax(), iris), iris)
model <- fit(model, iris_minmax[,1:4])
clu <- cluster(model, iris_minmax[,1:4])
table(clu)
clu 1 2 3 21 96 33
# evaluate model using external metric
eval <- evaluate(model, clu, iris_minmax$Species)
eval
x | ce | qtd | ceg |
---|---|---|---|
<fct> | <dbl> | <int> | <dbl> |
1 | 0.7024666 | 21 | 0.09834532 |
2 | 0.9987473 | 96 | 0.63919827 |
3 | 0.0000000 | 33 | 0.00000000 |