Skip to content

Commit

Permalink
Merge pull request mi-erasmusmc#3 from mi-erasmusmc/development
Browse files Browse the repository at this point in the history
Latest version
  • Loading branch information
AniekMarkus authored Mar 14, 2023
2 parents 21f8a50 + 290e618 commit e10d61f
Show file tree
Hide file tree
Showing 290 changed files with 402 additions and 151,740 deletions.
11 changes: 11 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
^.*\.Rproj$
^\.Rproj\.user$
^vignettes$
^output$
^docs$
^Meta$
^README\.Rmd$
^LICENSE\.md$
^\.github$
^_pkgdown\.yml$
^pkgdown$
48 changes: 46 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
.Rproj.user
# History files
.Rhistory

# Session Data files
.RData
.RDataTmp

# User-specific files
.Ruserdata
.DS_STORE

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# Produced vignettes
vignettes/*.html
vignettes/*.pdf

# R Environment Variables
.Renviron

# Documents and results
docs/
output/

# Mac files
.DS_STORE
.idea/

# Compiled Object files
*.o
*.obj

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Compiled Static libraries
*.a
*.lib

# Other C++ files
**/__history/

# EXPLORE result files
*.result
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(Explore)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O3")
set(CMAKE_VERBOSE_MAKEFILE ON)

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -stdlib=libc++")
Expand All @@ -28,8 +29,8 @@ include_directories(IOExplore)
include_directories(include /usr/local/include/)
link_directories(/usr/local/lib)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ltbb -fprofile-instr-generate -fcoverage-mapping")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ltbb --coverage")

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ltbb --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ltbb")


# LINUX
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(aucrocExplore)
export(aurocEXPLORE)
export(changeSetting)
export(getSetting)
export(predictExplore)
Expand Down
10 changes: 10 additions & 0 deletions R/HelperFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ changeSetting <- function(settings, parameter, input, default_setting) {
}

if (!is.null(input)) { # If input has a value -> update parameter in settings

# if (input=="custom") {
# if (parameter=="Accuracy") {input <- custom_Accuracy()}
# }

settings <- sub(current_setting, paste0(parameter, "=", input, ""), settings)

} else if (grepl(paste0("@",parameter), settings, fixed=TRUE)) { # If value is required in settings, use default value if possible
# TODO: extend list of patterns that are recognized as required settings

if(!is.na(default_setting)) {

# if (default_setting=="custom") {
# if (parameter=="Accuracy") {default_setting <- custom_Accuracy()}
# }

settings <- sub(current_setting, paste0(parameter, "=", default_setting, ""), settings)
} else{
warning(paste0('Default setting for ', parameter, ' is NA, but setting is required to replace @', parameter, "."))
Expand Down
12 changes: 7 additions & 5 deletions R/MainFunctions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO: add descriptions for package manual

#' trainExplore
#' trainExplore This function finds the best decision rule for the given dataset based using EXPLORE.
#'
#' @param output_path
#' @param train_data
Expand All @@ -10,6 +10,7 @@
#'
#' @return
#' @export
#' @import Rcpp RcppParallel
#'
#' @examples
trainExplore <- function(output_path, train_data = NULL, settings_path = NULL, file_name = "train_data", ...) {
Expand Down Expand Up @@ -190,7 +191,8 @@ predictExplore <- function(model, test_data) {
#' @export
#'
#' @examples
aucrocExplore <- function(output_path, train_data, settings_path, file_name, ...) {
aurocEXPLORE <- function(output_path, train_data, settings_path, file_name, ...) {
# TODO: check with latest implementation in PLP

# Range of specificities to check
specificities <- seq(from = 0.01, to = 0.99, by = 0.02)
Expand All @@ -212,8 +214,8 @@ aucrocExplore <- function(output_path, train_data, settings_path, file_name, ...
sensitivities[s] <- as.numeric(sensitivity)
}

aucroc <- simple_auc(TPR = rev(sensitivities), FPR = rev(1 - specificities))
plot(1-specificities, sensitivities)
auroc <- simple_auc(TPR = rev(sensitivities), FPR = rev(1 - specificities))
# plot(1-specificities, sensitivities)

return(aucroc)
return(auroc)
}
62 changes: 62 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(warning = FALSE,
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
out.width = "100%"
)
```

## Package overview
Functions to find a short and accurate decision rule in disjunctive normal form using the Exhaustive Procedure for LOgic-Rule Extraction (EXPLORE) algorithm. The application performs and exhaustive search on all Boolean Normal Form decision rules.

## Package installation

You can install the latest version of EXPLORE like so:

```{r, eval=FALSE}
install.packages("remotes")
remotes::install_github("mi-erasmusmc/EXPLORE")
```

Additional instructions: to be added.


## Example usage using iris dataset
```{r}
library(Explore)
library(farff)
```

Load data:
```{r, eval=FALSE}
data <- farff::readARFF("inst/examples/iris.arff")
output_path <- file.path(getwd(), "output/")
```

Fit model with defaults and/or input parameters:
```{r, eval=FALSE}
model <- Explore::trainExplore(output_path = output_path, file_name = "iris", train_data = data, ClassFeature = "'class'", PositiveClass = '"Iris-versicolor"')
```

Predict:
```{r, eval=FALSE}
prediction <- Explore::predictExplore(model, test_data = data)
```


Additional documentation includes:
- Vignette code examples in combination with PLP: [to be added](~/Documents/Git/Explore/vignettes/EXPLORE_withPLP.Rmd)
- Package manual: [to be added](~/Documents/Git/Explore/vignettes/Explore_1.0.pdf)


## Development status
EXPLORE is under active development.


## Publication
Rijnbeek, P.R., Kors, J.A. Finding a short and accurate decision rule in disjunctive normal form by exhaustive search. Machine Learning 80, 33–62 (2010). https://doi.org/10.1007/s10994-010-5168-9
60 changes: 53 additions & 7 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
# EXPLORE Package
Finding a short and accurate decision rule in disjunctive normal form by exhaustive search.
The application performs and exhaustive search on all Boolean Normal Form decision rules.

## User Documentation
Available documentation includes:
- Package manual: to be added.
## Package overview

Functions to find a short and accurate decision rule in disjunctive
normal form using the Exhaustive Procedure for LOgic-Rule Extraction
(EXPLORE) algorithm. The application performs and exhaustive search on
all Boolean Normal Form decision rules.

## Package installation

You can install the latest version of EXPLORE like so:

``` r
install.packages("remotes")
remotes::install_github("mi-erasmusmc/EXPLORE")
```

Additional instructions: to be added.

## Example usage using iris dataset

``` r
library(Explore)
library(farff)
```

Load data:

``` r
data <- farff::readARFF("inst/examples/iris.arff")
output_path <- file.path(getwd(), "output/")
```

Fit model with defaults and/or input parameters:

``` r
model <- Explore::trainExplore(output_path = output_path, file_name = "iris", train_data = data, ClassFeature = "'class'", PositiveClass = '"Iris-versicolor"')
```

Predict:

``` r
prediction <- Explore::predictExplore(model, test_data = data)
```

Additional documentation includes: - Vignette code examples in
combination with PLP: [to be
added](~/Documents/Git/Explore/vignettes/EXPLORE_withPLP.Rmd) - Package
manual: [to be added](~/Documents/Git/Explore/vignettes/Explore_1.0.pdf)

## Development status

EXPLORE is under active development.

## Publication
Rijnbeek, P.R., Kors, J.A. Finding a short and accurate decision rule in disjunctive normal form by exhaustive search. Mach Learn 80, 33–62 (2010). https://doi.org/10.1007/s10994-010-5168-9

Rijnbeek, P.R., Kors, J.A. Finding a short and accurate decision rule in
disjunctive normal form by exhaustive search. Machine Learning 80, 33–62
(2010). <https://doi.org/10.1007/s10994-010-5168-9>
File renamed without changes.
18 changes: 8 additions & 10 deletions inst/examples/iris.project
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[General]
Name=test
Remarks=test
DataFile=/Users/aniekmarkus/Documents/Git/Explore/data/iris.arff
DataFile=/Users/aniekmarkus/Documents/Git/Explore/inst/examples/iris.arff
Output=File
OutputFile=/Users/aniekmarkus/Documents/Git/Explore/tests/iris.result
OutputFile=@OutputFile
IncrementalOutputFile=false
[Setup]
PartitionMethod=RESUBSTITUTION
Expand All @@ -14,20 +14,20 @@ LearnRatio=0.8
NumberofPartitions=1
OperatorMethod=EXHAUSTIVE
CutoffMethod=RVAC
CutoffFile=/Users/aniekmarkus/Documents/Git/Explore/test/iris.cutoff
CutoffFile=/Users/aniekmarkus/Documents/Git/Explore/inst/examples/iris.cutoff
ClassFeature=class
PositiveClass=Iris-versicolor
[Restrictions]
Rule=
FeatureInclude=''
FeatureInclude=
FeatureRule=
[Constraints]
Maximize=ACCURACY
Accuracy=
Specificity=
[Output]
OutputMethod=BEST
PrintSettings=no
PrintSettings=yes
PrintPartitions=no
PrintFeatureOperators=no
PrintCutoffMethod=no
Expand All @@ -37,14 +37,12 @@ PrintOperatorValues=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutoffSetsBestLength=no
PrintPerformance=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
[Run]
OptimizeRules=yes
Subsumption=yes
BranchBound=yes



Parallel=no
Loading

0 comments on commit e10d61f

Please sign in to comment.