R/KSNN-C.R

Defines functions KSNN_C

Documented in KSNN_C

#Class implementing a Classification Algorithm
  #Implements the KSNN-C KEEL classification algorithm

KSNN_C <- function(train, test, k=1){
  alg <- RKEEL::R6_KSNN_C$new()
  alg$setParameters(train, test, k)
  return (alg)
}

R6_KSNN_C <- R6::R6Class("R6_KSNN_C",

  inherit = ClassificationAlgorithm,

  public = list(

    #Public properties

    #k: num of nearest neighbours
    k = 1,


    #Public functions

    #Initialize function
    setParameters = function(train, test, k=1){

      super$setParameters(train, test)

      self$k <- k

    }


  ),

  private = list(

    #Private properties

    #jar Filename
    jarName = "KSNN.jar",

    #algorithm name
    algorithmName = "KSNN-C",

    #String with algorithm name
    algorithmString = "K Symmetric Nearest Neighbors Classifier",


    #Private functions

    #Get the text with the parameters for the config file
    getParametersText = function(){

      text <- ""
      text <- paste0(text, "K Value = ", self$k, "\n")

      return(text)

    }
  )
)

Try the RKEEL package in your browser

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

RKEEL documentation built on Sept. 15, 2023, 1:08 a.m.