Title: | Fuzzy Adaptive Resonance Theory K-Means Clustering Technique |
---|---|
Description: | A set of function for clustering data observation with hybrid method Fuzzy ART and K-Means by Sengupta, Ghosh & Dan (2011) <doi:10.1080/0951192X.2011.602362>. |
Authors: | Alfi Nurrahmah [aut, cre] Budi Yuniarto [aut] |
Maintainer: | Alfi Nurrahmah <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-10-31 22:13:00 UTC |
Source: | https://github.com/alfinurrahmah/fakmct |
Calculates the similarity between the input pattern I and all of saved categories.
choice_function(input, category_w, alpha)
choice_function(input, category_w, alpha)
input |
The input (vector) data observation |
category_w |
The current category weight |
alpha |
Choice parameter alpha > 0 |
Returns the vector of Tj choice activation function
Clustering data observation with hybrid method Fuzzy ART and K-Means
fakmct( input, rho, alpha, beta, w_init = NA, max_epochs = 1000, max_clusters = 1000, eps = 10^-6 )
fakmct( input, rho, alpha, beta, w_init = NA, max_epochs = 1000, max_clusters = 1000, eps = 10^-6 )
input |
The input (vector) data observation. Should be numeric type of data. |
rho |
Vigilance parameter in (0,1) |
alpha |
Choice parameter alpha > 0 |
beta |
Learning rate in (0,1) |
w_init |
Initial weight |
max_epochs |
Maximum number of iterations |
max_clusters |
Maximum number of clusters that allowed |
eps |
Tolerance with default is 10^-6 |
labels |
clusters label of each observations |
size |
the size of each clusters that have been formed |
clusters |
a list of observations in each clusters |
centroids |
cluster centroids that are calculated by the mean value of the objects in each clusters |
weights |
the model weight |
params |
parameters that have been saved in the function |
num_clusters |
number of cluster that have been formed |
running.time |
time for running function |
library(fakmct) # Using dataset iris ## load data data.inputs = iris[,-5] true.labels = as.numeric(unlist(iris$Species)) ## run model data ex.iris<-fakmct(data.inputs, alpha = 0.3, rho = 0.5, beta = 1, max_epochs = 50, max_clusters = 5) ex.iris$labels ex.iris$size ex.iris$centroids ex.iris$params ## plot data plot(data.inputs, col = ex.iris$labels, pch = true.labels, main = paste0("Dataset: Iris")) # Using data IPM 2019 ## load simulate data IPM data("simulatedataIPM") dt <- simulatedataIPM ## run model data IPM mod.fakm<-fakmct(dt, alpha = 0.3, rho = 0.5, beta = 0.1, max_epochs = 50, max_clusters = 5) mod.fakm$labels mod.fakm$size mod.fakm$centroids mod.fakm$params ## plot data IPM plot(dt, col = mod.fakm$labels, pch=mod.fakm$labels, main = paste0("Dataset IPM"))
library(fakmct) # Using dataset iris ## load data data.inputs = iris[,-5] true.labels = as.numeric(unlist(iris$Species)) ## run model data ex.iris<-fakmct(data.inputs, alpha = 0.3, rho = 0.5, beta = 1, max_epochs = 50, max_clusters = 5) ex.iris$labels ex.iris$size ex.iris$centroids ex.iris$params ## plot data plot(data.inputs, col = ex.iris$labels, pch = true.labels, main = paste0("Dataset: Iris")) # Using data IPM 2019 ## load simulate data IPM data("simulatedataIPM") dt <- simulatedataIPM ## run model data IPM mod.fakm<-fakmct(dt, alpha = 0.3, rho = 0.5, beta = 0.1, max_epochs = 50, max_clusters = 5) mod.fakm$labels mod.fakm$size mod.fakm$centroids mod.fakm$params ## plot data IPM plot(dt, col = mod.fakm$labels, pch=mod.fakm$labels, main = paste0("Dataset IPM"))
Fuzzy And Function
fuzzy_and(inputA, inputB)
fuzzy_and(inputA, inputB)
inputA |
First input vector |
inputB |
Second input vector. Must be of the same dimension as inputA. |
Returns the Fuzzy AND of two input values in a vector.
fuzzy_and(0, -1) # = -1 fuzzy_and(0, 1) # = 0 fuzzy_and(1, 2) # = 1 fuzzy_and(1, 1) # = 1 fuzzy_and(c(0.5, 0.75), c(1.5, 1)) # = c(0.5,0.75)
fuzzy_and(0, -1) # = -1 fuzzy_and(0, 1) # = 0 fuzzy_and(1, 2) # = 1 fuzzy_and(1, 1) # = 1 fuzzy_and(c(0.5, 0.75), c(1.5, 1)) # = c(0.5,0.75)
Fuzzy Norm
fuzzy_norm(input)
fuzzy_norm(input)
input |
The input (vector) data observation |
Returns the Fuzzy norm results of input values
a = c(-1,-3,4,5) fuzzy_norm(a) # = 13
a = c(-1,-3,4,5) fuzzy_norm(a) # = 13
Linear Algebra for Euclidean distance
linalg_norm(inputA, inputB)
linalg_norm(inputA, inputB)
inputA |
First input vector |
inputB |
Second input vector. Must be of the same dimension as inputA. |
Returns the calculation results by squares of distances between two input values
a <- c(-3,-2,-1,3,3,2,3) b <- c(-3,-2,-1,0,1,2,3) linalg_norm(a,b) # = 3.605
a <- c(-3,-2,-1,3,3,2,3) b <- c(-3,-2,-1,0,1,2,3) linalg_norm(a,b) # = 3.605
Match function
match_function(input, category_w)
match_function(input, category_w)
input |
The input (vector) data observation |
category_w |
The current category weight |
Returns the vector of match Sj that will be used to check the vigilance parameter
A real data of Human Development Index (Indeks Pembangunan Manusia) of West Java, Indonesia 2019
simulatedataIPM
simulatedataIPM
A tibble
with 27 observation as region and 4 column as variables, which are:
a value of Life expectancy (Angka Harapan Hidup)
a value of Expected Years of Schooling (Harapan Lama Sekolah)
a value of Mean Years of Schooling (Rata-rata Lama Sekolah)
a value of Expenditure (Pengeluaran)
Update weight
update_weight(input, category_w, beta)
update_weight(input, category_w, beta)
input |
The input (vector) data observation |
category_w |
The current category weight |
beta |
Learning rate in (0,1) |
Returns the updated weight
Vigilance check
vigilance_check(input, category_w, rho)
vigilance_check(input, category_w, rho)
input |
The input (vector) data observation |
category_w |
The current category weight |
rho |
Vigilance parameter (0,1) |
Returns Boolean value (True or False) as a result of checking the match Sj vector passed the vigilance parameter or not