% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/kproto2silhouette.R
\name{kproto2silhouette}
\alias{kproto2silhouette}
\title{Compute individual Silhouette Widths}
\usage{
kproto2silhouette(object)
}
\arguments{
\item{object}{Object of class \code{kproto}.}
}
\value{
Object of class \code{silhouette} to be further used with \code{\link[cluster]{summary.silhouette}} 
or \code{\link[cluster]{plot.silhouette}}. It consists in a matrix where each row corresponds to one observation 
and the columns contain the assigned cluster as well as the neighbor cluster as well as the individual silhouette 
width ob the observation.
}
\description{
Computes an object of class \code{silhouette} from k-prototypes clustering for mixed-type data.
}
\details{
Information on the individual silhouette width for all observations is computed. 
The k-prototypes result of class \code{kproto} is turned into an object of class \code{silhouette} 
that can be further used with the functions \code{\link[cluster]{summary.silhouette}} or \code{\link[cluster]{plot.silhouette}}.
}
\examples{
# generate toy data with factors and numerics

n   <- 50
prb <- 0.9
muk <- 1.5 
clusid <- rep(1:4, each = n)

x1 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x1 <- c(x1, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x1 <- as.factor(x1)

x2 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x2 <- c(x2, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x2 <- as.factor(x2)

x3 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))
x4 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))

x <- data.frame(x1,x2,x3,x4)

# apply k-prototypes
kpres <- kproto(x, 4)

# compute silhouette widhts
# extract object of class sil
sils <- kproto2silhouette(kpres)

# apply functions from package cluster
library(cluster)
summary(sils)
plot(sils)

# compute average silhouette width  
mean(sils[,3])

# ...alternatively, compute average silhouette width directly using validation_kproto() 
cindex_value <- validation_kproto(method = "silhouette", object = kpres)
cindex_value

}
\references{
\itemize{
    \item Szepannek, G. (2018): 
    clustMixType: User-Friendly Clustering of Mixed-Type Data in R, 
    {\emph{The R Journal 10/2}}, 200-208. 
    \doi{10.32614/RJ-2018-048}.
    
    \item Aschenbruck, R., Szepannek, G. (2020): 
    Cluster Validation for Mixed-Type Data. 
    \emph{Archives of Data Science, Series A, Vol 6, Issue 1}.
    \doi{10.5445/KSP/1000098011/02}.
    
    \item Kaufman, L., Rousseeuw, P. (1990): 
    \emph{Finding Groups in Data: An Introduction to Cluster Analysis.} 
     Wiley.
  }
}
\author{
\email{gero.szepannek@web.de}
}
