janusza / RoughSets

RoughSets package for R System
37 stars 13 forks source link

The example of C.FRNN.FRST failure #5

Open AI-Surfing opened 7 years ago

AI-Surfing commented 7 years ago

I execute the following code in RStudio, but have a error "Error in x - temp.obj : non-numeric argument to binary operator"

data(iris)
## shuffle the data
set.seed(2)
irisShuffled <- iris[sample(nrow(iris)),]
## transform values of the decision attribute into numerics
irisShuffled[,5] <- unclass(irisShuffled[,5])
## split the data into training and testing data
iris.training <- irisShuffled[1:105,]
iris.testing <- irisShuffled[106:nrow(irisShuffled),1:4]
colnames(iris.training) <- c("Sepal.Length", "Sepal.Width", "Petal.Length",
                             "Petal.Width", "Species")
## convert into a standard decision table
decision.table <- SF.asDecisionTable(dataset = iris.training, decision.attr = 5,
                                     indx.nominal = c(5))
tst.iris <- SF.asDecisionTable(dataset = iris.testing)
###### FRNN algorithm using lower/upper approximation:
###### Implicator/tnorm based approach
control <- list(type.LU = "implicator.tnorm", k = 20,
                type.aggregation = c("t.tnorm", "lukasiewicz"),
                type.relation = c("tolerance", "eq.1"), t.implicator = "lukasiewicz")
res.1 <- C.FRNN.FRST(decision.table = decision.table, newdata = tst.iris,control = control)

Although the function unclass has tranform the values of the decision attribute into numerics, the parameter indx.nominal = c(5) in SF.asDecision.Table designates it as the nominal variable again. When execute the C.FRNN.FRST function, the error occured. When comment out the parameter indx.nominal = c(5), the codes could be executed normally, but the classification results is very poor.There are three classes in the decision attribute, the predicted class only have two.

amjiuzi commented 6 years ago

when run demo with 3. Prediction using fuzzy nearest neighbor classifiers got error bellow, wish yr reply @janusza

Examples: Data analysis using the wine dataset

  1. Prediction using fuzzy nearest neighbor classifiers
    control.frnn.o <- list(m = 2,
                       type.membership = "gradual")
    predValues.frnn.o <- C.FRNN.O.FRST(wine.tra.is,
                                   newdata = wine.tst.fs, 
                                   control = control.frnn.o)
    Error in dt.ori[i, j] - range.data[1, j] : 
    non-numeric argument to binary operator