Giter VIP home page Giter VIP logo

survivalsvm's Introduction

Travis Build Status AppVeyor Build Status Coverage Status

Survival Support Vector Analysis

Cesaire J. K. Fouodo

Introduction

This package performs support vectors analysis for data sets with survival outcome. Three approaches are available in the package: The regression approach takes censoring into account when formulating the inequality constraints of the support vector problem. In the ranking approach, the inequality constraints set the objective to maximize the concordance index for comparable pairs of observations. The hybrid approach combines the regression and ranking constraints in the same model.

Installation

Installation from Github:

devtools::install_github("imbs-hl/survivalsvm")

CRAN release coming soon.

Usage

For usage in R, see ?survivalsvm in R. Most importantly, see the Examples section. As a first example you could try

survivalsvm(Surv(time, status) ~ ., veteran, gamma.mu = 0.1)

References

  • Van Belle, V., Pelcmans, K., Van Huffel S. and Suykens J. A.K. (2011a). Improved performance on high-dimensional survival data by application of Survival-SVM. Bioinformatics (Oxford, England) 27, 87-94.
  • Van Belle, V., Pelcmans, K., Van Huffel S. and Suykens J. A.K. (2011b). Support vector methods for survival analysis: a comparaison between ranking and regression approaches. Artificial Intelligence in medecine 53, 107-118.

survivalsvm's People

Contributors

fouodo avatar mnwright avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

survivalsvm's Issues

Help wanted: control number of parallel processes

Is there a possibility to explicictly control / specify the number of processes / CPU threads that are used when running survivalsvm?

I realized that running survivalsvm::survivalsvm() with the argument opt.meth = "ipop" uses all available CPU resources, whereas running it with opt.meth = "quadprog" seems use one CPU thread only.

Many thanks in advance.

How to extract the prediction weight of each variable

Thanks for the powerful tools, but I was confused about how to measure the importance of each variable. Thus it was difficult to explain which variable plays the main role in the prediction,

As Maverick Meerkat says, the weight can be calculated as t(fit$SV)%*% fit$coefs when the binary classification. So could I use a similar definition t(fit$model.fit$SV) %*% fit$model.fit$Beta as the weight of each variable? Or any other options? Thanks.

Error when using kernel = "poly_kernel"

Hi there,
I'm trying to set the poly_kernel in survivalsvm, But I always get this error: Error in cbind(K, -delta * K) : dims [product 36] do not match the length of object [137] In addition: Warning message: In -delta * K : longer object length is not a multiple of shorter object length.
And I can't fing any help about the poly_kernel. Here's the code:

library(survival)
library(survivalsvm)
survsvm.reg <- survivalsvm(formula = Surv(diagtime, status) ~ ., data = veteran,
                           type = "regression", gamma.mu = 0.1,
                           opt.meth = "ipop", kernel = "poly_kernel")

Could you please give me any suggestions? Thank you very much.

survivalsm function fails using another dataset

Hi @mnwright,

Thanks for sharing this package and I've been trying to use it on my own dataset. However, when using the code like this:
survsvm.reg1 <- survivalsvm(Surv(follow_up, event) ~ AGE.bl+PTGENDER+PTEDUCAT , data = study1, type = "regression", gamma.mu = 1, opt.meth = "quadprog", kernel = "add_kernel")
An error shows up:
image
There are definitely observations in the dataset study1, and follow_up and event are all num.

Could you please let me know where goes wrong? Thanks!

Calculation of the concordance index

I followed the example from your paper (see below) and then tried to compute the concordance index using your function conindex. But I get a much lower value than you achieved. Similarly when I run the same test on my own data I get a very low concordance index using conindex.

  1. How did you calculate the c-index values reported in your paper?
  2. Am I doing something wrong?
data(veteran, package = "survival")
set.seed(123)
n <- nrow(veteran)
train.index <- sample(1:n, 0.7 * n, replace = FALSE)
test.index <- setdiff(1:n, train.index)

survsvm.reg <- survivalsvm(Surv(diagtime, status) ~ .,
                           subset = train.index, data = veteran,
                           type = "regression", gamma.mu = 1,
                           opt.meth = "quadprog", kernel = "add_kernel")

print(survsvm.reg)

pred.survsvm.reg <- predict(object = survsvm.reg,
                            newdata = veteran, subset = test.index)

print(pred.survsvm.reg)
conindex(pred.survsvm.reg, veteran$time[test.index])
survivalsvm result

Call:

 survivalsvm(Surv(diagtime, status) ~ ., subset = train.index, data = veteran, type = "regression", gamma.mu = 1, opt.meth = "quadprog", kernel = "add_kernel") 

Survival svm approach              : regression 
Type of Kernel                     : add_kernel 
Optimization solver used           : quadprog 
Number of support vectors retained : 39 
survivalsvm version                : 0.0.5 


survivalsvm prediction

Type of survivalsvm                      : regression 
Type of kernel                           : add_kernel 
Optimization solver used in model        : quadprog 
predicted risk ranks                     : 13.89 14.95 11.12 15.6 10.7 ...
survivalsvm version                      : 0.0.5 
  C Index 
0.5005848 

prediction should warn if/which rows are removed

see:

X_pred <- X_pred[stats::complete.cases(X_pred),]

library(survival)
library(survivalsvm)

set.seed(123)
n <- nrow(veteran)

train.index <- sample(seq_len(n), 0.7*n, replace = FALSE)
test.index <- setdiff(seq_len(n), train.index)

train <- veteran[train.index, , drop = FALSE]
test <- veteran[test.index, , drop = FALSE]

test[1, "karno"] <- NA_real_

survsvm.reg <- survivalsvm(
  Surv(diagtime, status) ~ .,
  data = train,
  type = "regression",
  gamma.mu = 1,
  opt.meth = "quadprog",
  kernel = "add_kernel"
)

pred.survsvm.reg <- predict(
  object = survsvm.reg,
  newdata = test
)

conindex(
  pred.survsvm.reg,
  Surv(test$diagtime, test$status)
)
#> Error in conindex(pred.survsvm.reg, Surv(test$diagtime, test$status)): Error: lengths do not macht.


complete_rows <- complete.cases(test)
conindex(
  pred.survsvm.reg,
  Surv(
    test$diagtime[complete_rows],
    test$status[complete_rows]
  )
)
#>   C Index 
#> 0.7109905

Created on 2022-04-27 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Italian_Italy.1252
#>  ctype    Italian_Italy.1252
#>  tz       Europe/Berlin
#>  date     2022-04-27
#>  pandoc   2.14.0.3 @ C:/Program Files/RStudio/bin/pandoc/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version date (UTC) lib source
#>  assertthat     0.2.1   2019-03-21 [1] CRAN (R 4.1.2)
#>  backports      1.4.1   2021-12-13 [1] CRAN (R 4.1.2)
#>  base64enc      0.1-3   2015-07-28 [1] CRAN (R 4.1.1)
#>  checkmate      2.0.0   2020-02-06 [1] CRAN (R 4.1.2)
#>  cli            3.1.1   2022-01-20 [1] CRAN (R 4.1.2)
#>  cluster        2.1.2   2021-04-17 [2] CRAN (R 4.1.2)
#>  colorspace     2.0-2   2021-06-24 [1] CRAN (R 4.1.2)
#>  crayon         1.4.2   2021-10-29 [1] CRAN (R 4.1.2)
#>  data.table     1.14.2  2021-09-27 [1] CRAN (R 4.1.2)
#>  DBI            1.1.2   2021-12-20 [1] CRAN (R 4.1.2)
#>  digest         0.6.29  2021-12-01 [1] CRAN (R 4.1.2)
#>  dplyr          1.0.7   2021-06-18 [1] CRAN (R 4.1.2)
#>  ellipsis       0.3.2   2021-04-29 [1] CRAN (R 4.1.2)
#>  evaluate       0.14    2019-05-28 [1] CRAN (R 4.1.2)
#>  fansi          1.0.2   2022-01-14 [1] CRAN (R 4.1.2)
#>  fastmap        1.1.0   2021-01-25 [1] CRAN (R 4.1.2)
#>  foreign        0.8-81  2020-12-22 [2] CRAN (R 4.1.2)
#>  Formula        1.2-4   2020-10-16 [1] CRAN (R 4.1.1)
#>  fs             1.5.2   2021-12-08 [1] CRAN (R 4.1.2)
#>  generics       0.1.2   2022-01-31 [1] CRAN (R 4.1.2)
#>  ggplot2        3.3.5   2021-06-25 [1] CRAN (R 4.1.2)
#>  glue           1.6.1   2022-01-22 [1] CRAN (R 4.1.2)
#>  gridExtra      2.3     2017-09-09 [1] CRAN (R 4.1.2)
#>  gtable         0.3.0   2019-03-25 [1] CRAN (R 4.1.2)
#>  highr          0.9     2021-04-16 [1] CRAN (R 4.1.2)
#>  Hmisc          4.6-0   2021-10-07 [1] CRAN (R 4.1.2)
#>  htmlTable      2.4.0   2022-01-04 [1] CRAN (R 4.1.2)
#>  htmltools      0.5.2   2021-08-25 [1] CRAN (R 4.1.2)
#>  htmlwidgets    1.5.4   2021-09-08 [1] CRAN (R 4.1.2)
#>  jpeg           0.1-9   2021-07-24 [1] CRAN (R 4.1.1)
#>  knitr          1.37    2021-12-16 [1] CRAN (R 4.1.2)
#>  lattice        0.20-45 2021-09-22 [2] CRAN (R 4.1.2)
#>  latticeExtra   0.6-29  2019-12-19 [1] CRAN (R 4.1.2)
#>  lifecycle      1.0.1   2021-09-24 [1] CRAN (R 4.1.2)
#>  magrittr       2.0.2   2022-01-26 [1] CRAN (R 4.1.2)
#>  Matrix         1.3-4   2021-06-01 [2] CRAN (R 4.1.2)
#>  munsell        0.5.0   2018-06-12 [1] CRAN (R 4.1.2)
#>  nnet           7.3-16  2021-05-03 [2] CRAN (R 4.1.2)
#>  pillar         1.7.0   2022-02-01 [1] CRAN (R 4.1.2)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.1.2)
#>  png            0.1-7   2013-12-03 [1] CRAN (R 4.1.1)
#>  pracma         2.3.6   2021-12-07 [1] CRAN (R 4.1.2)
#>  purrr          0.3.4   2020-04-17 [1] CRAN (R 4.1.2)
#>  quadprog       1.5-8   2019-11-20 [1] CRAN (R 4.1.1)
#>  R.cache        0.15.0  2021-04-30 [1] CRAN (R 4.1.3)
#>  R.methodsS3    1.8.1   2020-08-26 [1] CRAN (R 4.1.1)
#>  R.oo           1.24.0  2020-08-26 [1] CRAN (R 4.1.1)
#>  R.utils        2.11.0  2021-09-26 [1] CRAN (R 4.1.3)
#>  R6             2.5.1   2021-08-19 [1] CRAN (R 4.1.2)
#>  RColorBrewer   1.1-2   2014-12-07 [1] CRAN (R 4.1.1)
#>  reprex         2.0.1   2021-08-05 [1] CRAN (R 4.1.3)
#>  rlang          1.0.1   2022-02-03 [1] CRAN (R 4.1.2)
#>  rmarkdown      2.11    2021-09-14 [1] CRAN (R 4.1.2)
#>  rpart          4.1-15  2019-04-12 [2] CRAN (R 4.1.2)
#>  rstudioapi     0.13    2020-11-12 [1] CRAN (R 4.1.2)
#>  scales         1.1.1   2020-05-11 [1] CRAN (R 4.1.2)
#>  sessioninfo    1.2.2   2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi        1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr        1.4.0   2019-02-10 [1] CRAN (R 4.1.2)
#>  styler         1.7.0   2022-03-13 [1] CRAN (R 4.1.3)
#>  survival     * 3.2-13  2021-08-24 [2] CRAN (R 4.1.2)
#>  survivalsvm  * 0.0.5   2018-02-05 [1] CRAN (R 4.1.2)
#>  tibble         3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  tidyselect     1.1.1   2021-04-30 [1] CRAN (R 4.1.2)
#>  utf8           1.2.2   2021-07-24 [1] CRAN (R 4.1.2)
#>  vctrs          0.3.8   2021-04-29 [1] CRAN (R 4.1.2)
#>  withr          2.4.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  xfun           0.29    2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml           2.2.2   2022-01-25 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Users/FedericoScognamiglio/OneDrive - Unit of Biostatistics Epidemiology and Public Health/Documenti/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.2/library
#> 
#> ------------------------------------------------------------------------------

Feature selection with Survival-SVM

Dear maintainers,

I'm using this excellent package to conduct my research. This package has implemented the SVM methods for survival analysis from Van Belle et al. According to their Bioinformatics paper (2011): "Improved performance on high-dimensional survival data by application of Survival-SVM", a feature selection technique is proposed in Section 2.3.2 & 2.3.3.

Is this package able to deal with this part? Or do you intend to implement this useful technique in the future?

Best regards,
Darren Tsai

Cross Validation

Dear author, thank you for creating this valuable tool.
I would like to know how to run this method using 5-fold or 10-fold cross-validation, as it can help me determine the optimal parameters.
I hope to receive your help.
Best wishes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.