Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg committed Oct 5, 2018
1 parent 822bb74 commit 3a0eb1b
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
^tic\.R$
^appveyor\.yml$
.ignore
.editorconfig
.gitignore
^\.travis\.yml$
^.*\.Rproj$
^\.Rproj\.user$
^man-roxygen$
^attic$
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See http://editorconfig.org
root = true

[*]
charset = utf8
end_of_line = lf
insert_final_newline = true
indent_style = space
trim_trailing_whitespace = true

[*.{r,R,md,Rmd}]
indent_size = 2

[*.{c,h}]
indent_size = 4

[*.{cpp,hpp}]
indent_size = 4

[{NEWS.md,DESCRIPTION,LICENSE}]
max_line_length = 80
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData
# Example code in package build process
*-Ex.R
# Output files from R CMD build
/*.tar.gz
# Output files from R CMD check
/*.Rcheck/
# RStudio files
.Rproj.user/
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth
# knitr and R markdown default cache directories
/*_cache/
/cache/
# Temporary files created by R markdown
*.utf8.md
*.knit.md
inst/doc

.DS_Store
.Rproj.user
5 changes: 5 additions & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
man/
docs/
inst/doc/
attic/
vignettes/*.html
31 changes: 31 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Package: mlr3learners
Title: Recommended learners for mlr3
Version: 0.1.0-9000
Authors@R:
person(given = "Michel",
family = "Lang",
role = c("cre", "aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-9754-0393"))
Description: Recommended Learners for mlr3. Extends mlr3 with interfaces to the
most popular machine learning packages on CRAN.
License: MIT + file LICENSE
Depends:
R (>= 3.1.0)
Imports:
backports,
mlr3,
paradox,
R6
Suggests:
ranger,
testthat
VignetteBuilder:
knitr
ByteCompile: true
Encoding: UTF-8
NeedsCompilation: no
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.0
URL: https://github.com/mlr-org/mlr3learners
BugReports: https://github.com/mlr-org/mlr3learners/issues
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by roxygen2: do not edit by hand

import(paradox)
importFrom(R6,R6Class)
importFrom(mlr3,LearnerClassif)
importFrom(mlr3,mlr_learners)
38 changes: 38 additions & 0 deletions R/mlr_learners_classif_ranger.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
LearnerClassifRanger = R6Class("LearnerClassifRanger", inherit = LearnerClassif,
public = list(
initialize = function(id = "classif.ranger") {
super$initialize(
id = id,
packages = "ranger",
feature_types = c("logical", "integer", "numeric", "character", "factor", "ordered"),
predict_types = c("response", "prob"),
par_set = ParamSet$new(
params = list(
ParamInt$new(id = "num.trees", default = 500L, lower = 1L),
ParamReal$new(id = "mtry", lower = 1)
)
),
properties = c("twoclass", "multiclass")
)
},

train = function(task, ...) {
ranger::ranger(task$formula, task$data(), probability = (self$predict_type == "prob"), ...)
},

predict = function(model, task, ...) {
newdata = task$data(cols = task$feature_names)
preds = predict(model, data = newdata, predict.type = "response")

if (self$predict_type == "response") {
prob = NULL
response = preds$predictions
} else {
prob = preds$predictions
response = colnames(prob)[apply(prob, 1, which.max)]
}

PredictionClassif$new(task, response, prob)
}
)
)
8 changes: 8 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' @import paradox
#' @importFrom R6 R6Class
#' @importFrom mlr3 mlr_learners LearnerClassif
"_PACKAGE"

.onLoad = function(libname, pkgname) {
mlr_learners$add("classif.ranger", LearnerClassifRanger)
}
23 changes: 23 additions & 0 deletions man/mlr3learners-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions mlr3learner.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

0 comments on commit 3a0eb1b

Please sign in to comment.