Running ‘test_all.R’ [16s/14s]
Running the tests in ‘tests/test_all.R’ failed.
Complete output:
  > library(testthat)
  > library(SVMMaj)
  > test_check("SVMMaj")
  ── 1. Error: Can handle constant attribute set (@test_svmmaj.R#108)  ───────────
  Number of classes must be equal to 2
  Backtrace:
   1. SVMMaj::svmmaj(X, y)
   2. SVMMaj:::svmmaj.default(X, y)
  
  
  svmmaj> ## using default settings
  svmmaj> model1 <- svmmaj(
  svmmaj+  diabetes$X, diabetes$y, hinge = 'quadratic', lambda = 1)
  
  svmmaj> summary(model1)
  Call:
     svmmaj.default(X = diabetes$X, y = diabetes$y, lambda = 1, hinge = "quadratic")
  
  Settings:
      lambda                             1 
      hinge error                        quadratic 
      spline basis                       no 
      type of kernel                     linear 
  
  Data:
      class labels                       negative positive 
      rank of X                          8 
      number of predictor variables      8 
      number of objects                  768 
      omitted objects                    0 
  
  Model:
      update method                      svd 
      number of iterations               9 
      loss value                         490.0413 
      number of support vectors          691 
  
  Confusion matrix:
              Predicted(yhat)
  Observed (y) negative positive Total
      negative      446       54   500
      positive      115      153   268
      Total         561      207   768
  
  Classification Measures:
                                            
     hit rate                           0.78
     weighted hit rate                  0.78
     misclassification rate             0.22
     weighted missclassification rate   0.22
  
                      TP        FP Precision
      negative     0.892     0.108     0.795
      positive     0.571     0.429     0.739
  
  svmmaj> weights.obs = list(positive = 2, negative = 1)
  
  svmmaj> ## using radial basis kernel
  svmmaj> library(kernlab)
  
  svmmaj> model2 <- svmmaj(
  svmmaj+   diabetes$X, diabetes$y, hinge = 'quadratic', lambda = 1, 
  svmmaj+   weights.obs = weights.obs, scale = 'interval',
  svmmaj+   kernel = rbfdot,
  svmmaj+   kernel.sigma = 1
  svmmaj+ )
  
  svmmaj> summary(model2)
  Call:
     svmmaj.default(X = diabetes$X, y = diabetes$y, lambda = 1, weights.obs = weights.obs, 
      scale = "interval", kernel = rbfdot, kernel.sigma = 1, hinge = "quadratic")
  
  Settings:
      lambda                             1 
      hinge error                        quadratic 
      spline basis                       no 
      type of kernel                     rbfkernel 
      parameters of kernel               degree = 1  offset = 1  scale = 1  sigma = 1  
  Data:
      class labels                       negative positive 
      rank of X                          221 
      number of predictor variables      8 
      number of objects                  768 
      omitted objects                    0 
  
  Model:
      update method                      Eigen 
      number of iterations               11 
      loss value                         643.2998 
      number of support vectors          686 
  
  Confusion matrix:
              Predicted(yhat)
  Observed (y) negative positive Total
      negative      376      124   500
      positive       54      214   268
      Total         430      338   768
  
  Classification Measures:
                                             
     hit rate                           0.768
     weighted hit rate                  0.776
     misclassification rate             0.232
     weighted missclassification rate   0.224
  
                      TP        FP Precision
      negative     0.752     0.248     0.874
      positive     0.799     0.201     0.633
  
  svmmaj> ## I-spline basis
  svmmaj> library(ggplot2)
  
  svmmaj> model3 <- svmmaj(
  svmmaj+   diabetes$X, diabetes$y, weight.obs = weight.obs,
  svmmaj+   spline.knots = 3, spline.degree = 2
  svmmaj+ )
  
  svmmaj> plotWeights(model3, plotdim = c(2, 4))
  TableGrob (3 x 3) "arrange": 9 grobs
    z     cells    name              grob
  1 1 (1-1,1-1) arrange    gtable[layout]
  2 2 (1-1,2-2) arrange    gtable[layout]
  3 3 (1-1,3-3) arrange    gtable[layout]
  4 4 (2-2,1-1) arrange    gtable[layout]
  5 5 (2-2,2-2) arrange    gtable[layout]
  6 6 (2-2,3-3) arrange    gtable[layout]
  7 7 (3-3,1-1) arrange    gtable[layout]
  8 8 (3-3,2-2) arrange    gtable[layout]
  9 9 (3-3,3-3) arrange gtable[guide-box]
  Number of observations:  200 
  Varying parameters    :  1 
  Number of gridpoints  :  3 
  Start cross validation ... 
     group 0 of 5 : ***
     group 1 of 5 : ***
     group 2 of 5 : ***
     group 3 of 5 : ***
     group 4 of 5 : ***
     group 5 of 5 : ***
  Getting optimal parameters ... 
  Done 
  Number of observations:  200 
  Varying parameters    :  2 
  Number of gridpoints  :  15 
  Start cross validation ... 
  Getting optimal parameters ... 
  Done 
  ══ testthat results  ═══════════════════════════════════════════════════════════
  [ OK: 13 | SKIPPED: 4 | WARNINGS: 1 | FAILED: 1 ]
  1. Error: Can handle constant attribute set (@test_svmmaj.R#108) 
  
  Error: testthat unit tests failed
  Execution halted