-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
damirpolat
committed
Oct 18, 2020
1 parent
b6f67e4
commit 1aaf234
Showing
5 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#' @title Cobweb Clustering Learner | ||
#' | ||
#' @name mlr_learners_clust.cobweb | ||
#' @include LearnerClust.R | ||
#' | ||
#' @description | ||
#' A [LearnerClust] for Cobweb clustering implemented in [RWeka::Cobweb()]. | ||
#' The predict method uses [RWeka::predict.Weka_clusterer()] to compute the | ||
#' cluster memberships for new data. | ||
#' | ||
#' @templateVar id clust.cobweb | ||
#' @template section_dictionary_learner | ||
#' @template example | ||
#' | ||
#' @export | ||
LearnerClustCobweb = R6Class("LearnerClustCobweb", | ||
inherit = LearnerClust, | ||
public = list( | ||
#' @description | ||
#' Creates a new instance of this [R6][R6::R6Class] class. | ||
initialize = function() { | ||
ps = ParamSet$new( | ||
params = list( | ||
ParamDbl$new(id = "A", default = 1, lower = 0, tags = "train"), | ||
ParamDbl$new(id = "C", default = 0.002, lower = 0, tags = "train"), | ||
ParamInt$new(id = "S", default = 42L, lower = 1L, tags = "train") | ||
) | ||
) | ||
|
||
super$initialize( | ||
id = "clust.cobweb", | ||
feature_types = c("logical", "integer", "numeric"), | ||
predict_types = "partition", | ||
param_set = ps, | ||
properties = c("partitional", "exclusive", "complete"), | ||
packages = "RWeka" | ||
) | ||
} | ||
), | ||
|
||
private = list( | ||
.train = function(task) { | ||
pv = self$param_set$get_values(tags = "train") | ||
ctrl = do.call(RWeka::Weka_control, pv) | ||
invoke(RWeka::Cobweb, x = task$data(), control = ctrl) | ||
}, | ||
|
||
.predict = function(task) { | ||
partition = predict(self$model, newdata = task$data(), type = "class") + 1L | ||
PredictionClust$new(task = task, partition = partition) | ||
} | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.