Package 'fakmct'

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

Help Index


Choice Function

Description

Calculates the similarity between the input pattern I and all of saved categories.

Usage

choice_function(input, category_w, alpha)

Arguments

input

The input (vector) data observation

category_w

The current category weight

alpha

Choice parameter alpha > 0

Value

Returns the vector of Tj choice activation function


Fuzzy Adaptive Resonance Theory (ART) K-Means Clustering Technique

Description

Clustering data observation with hybrid method Fuzzy ART and K-Means

Usage

fakmct(
  input,
  rho,
  alpha,
  beta,
  w_init = NA,
  max_epochs = 1000,
  max_clusters = 1000,
  eps = 10^-6
)

Arguments

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

Value

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

Examples

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

Description

Fuzzy And Function

Usage

fuzzy_and(inputA, inputB)

Arguments

inputA

First input vector

inputB

Second input vector. Must be of the same dimension as inputA.

Value

Returns the Fuzzy AND of two input values in a vector.

Examples

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

Description

Fuzzy Norm

Usage

fuzzy_norm(input)

Arguments

input

The input (vector) data observation

Value

Returns the Fuzzy norm results of input values

Examples

a = c(-1,-3,4,5)
fuzzy_norm(a) # = 13

Linear Algebra for Euclidean distance

Description

Linear Algebra for Euclidean distance

Usage

linalg_norm(inputA, inputB)

Arguments

inputA

First input vector

inputB

Second input vector. Must be of the same dimension as inputA.

Value

Returns the calculation results by squares of distances between two input values

Examples

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

Description

Match function

Usage

match_function(input, category_w)

Arguments

input

The input (vector) data observation

category_w

The current category weight

Value

Returns the vector of match Sj that will be used to check the vigilance parameter


Sample Data for simulate analysis data (Using IPM 2019)

Description

A real data of Human Development Index (Indeks Pembangunan Manusia) of West Java, Indonesia 2019

Usage

simulatedataIPM

Format

A tibble with 27 observation as region and 4 column as variables, which are:

"AHH"

a value of Life expectancy (Angka Harapan Hidup)

"HLS"

a value of Expected Years of Schooling (Harapan Lama Sekolah)

"RLS"

a value of Mean Years of Schooling (Rata-rata Lama Sekolah)

"Pengeluaran"

a value of Expenditure (Pengeluaran)

Source

https://www.bps.go.id/


Update weight

Description

Update weight

Usage

update_weight(input, category_w, beta)

Arguments

input

The input (vector) data observation

category_w

The current category weight

beta

Learning rate in (0,1)

Value

Returns the updated weight


Vigilance check

Description

Vigilance check

Usage

vigilance_check(input, category_w, rho)

Arguments

input

The input (vector) data observation

category_w

The current category weight

rho

Vigilance parameter (0,1)

Value

Returns Boolean value (True or False) as a result of checking the match Sj vector passed the vigilance parameter or not