R/predict.R

#
#  Copyright (C) 2005 Friedrich Leisch
#  $Id: predict.R 222 2017-03-03 16:29:43Z leisch $
#

setMethod("clusters", signature(object="flexclust", newdata="missing"),
function(object, newdata)
{
    object@cluster
})

setMethod("clusters", signature(object="flexclust", newdata="ANY"),
function(object, newdata, ...)
{
    predict(object, newdata, ...)
})


setMethod("predict", signature(object="kccasimple"),
function(object, newdata=NULL, ...)
{
    if(is.null(newdata)){
        z <- object@cluster
    }
    else{
        newdata <- as(newdata, "matrix")
        newdata <- object@family@preproc(newdata)
        z <- object@family@cluster(newdata, object@centers)
        names(z) <- rownames(newdata)
    }
    z
})

Try the flexclust package in your browser

Any scripts or data that you put into this service are public.

flexclust documentation built on April 8, 2022, 5:09 p.m.