ClustPredictor {FACT} | R Documentation |
Clustering Predictor Object
Description
A ClustPredictor
object holds any unsupervised clustering algorithm
and the data to be used for analyzing the model. The interpretation methods
in the FACT
package need the clustering algorithm to be wrapped in a
ClustPredictor
object.
Details
A Cluster Predictor object is a container for the unsupervised prediction model and the data. This ensures that the clustering algorithm can be analyzed in a robust way. The Model inherits from iml::Predictor Object and adjusts this Object to contain unsupervised Methods.
Super class
iml::Predictor
-> ClustPredictor
Public fields
type
character(1)
Either partition for cluster assignments or prob for soft labels. Can be decided by chosen by the user when initializing the object. IfNULL
, it checks the the dimensions ofy
.cnames
character
IsNULL
, if hard labeling is used. If soft labels are used, column names ofy
are being transferred.
Methods
Public methods
Inherited methods
Method new()
Create a ClustPredictor object
Usage
ClustPredictor$new( model = NULL, data = NULL, predict.function = NULL, y = NULL, batch.size = 1000, type = NULL )
Arguments
model
any
The trained clustering algorithm. Recommended are models frommlr3cluster
. For other clustering algorithms predict functions need to be specified.data
data.frame
The data to be used for analyzing the prediction model. Allowed column classes are: numeric, factor, integer, ordered and characterpredict.function
function
The function to assign newdata. Only needed ifmodel
is not a model frommlr3cluster
. The first argument ofpredict.fun
has to be the model, the second thenewdata
:function(model, newdata)
y
any
A integer vector representing the assigned clusters or a data.frame representing the soft labels per cluster assigned in columns.batch.size
numeric(1)
The maximum number of rows to be input the model for prediction at once. Currently only respected for SMART.type
character(1)
)
This argument is passed to the prediction function of the model. For soft label predictions, usetype="prob"
. For hard label predictions, usetype="partition"
. Consult the documentation or definition of the clustering algorithm you use to find which type options you have.
Method clone()
The objects of this class are cloneable with this method.
Usage
ClustPredictor$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
require(factoextra)
require(FuzzyDBScan)
multishapes <- as.data.frame(multishapes[, 1:2])
eps = c(0, 0.2)
pts = c(3, 15)
res <- FuzzyDBScan$new(multishapes, eps, pts)
res$plot("x", "y")
# create hard label predictor
predict_part = function(model, newdata) model$predict(new_data = newdata, cmatrix = FALSE)$cluster
ClustPredictor$new(res, as.data.frame(multishapes), y = res$clusters,
predict.function = predict_part, type = "partition")
# create soft label predictor
predict_prob = function(model, newdata) model$predict(new_data = newdata)
ClustPredictor$new(res, as.data.frame(multishapes), y = res$results,
predict.function = predict_prob, type = "prob")