File: ClusterTask.R

package info (click to toggle)
r-cran-mlr 2.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,264 kB
  • sloc: ansic: 65; sh: 13; makefile: 5
file content (31 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#' @title Create a cluster task.
#' @inheritParams Task
#' @seealso [Task] [ClassifTask] [CostSensTask] [MultilabelTask] [RegrTask] [SurvTask]
#' @rdname ClusterTask
#' @aliases ClusterTask
#' @export
makeClusterTask = function(id = deparse(substitute(data)), data, weights = NULL, blocking = NULL, coordinates = NULL, fixup.data = "warn", check.data = TRUE) {
  assertString(id)
  assertDataFrame(data)
  assertChoice(fixup.data, choices = c("no", "quiet", "warn"))
  assertFlag(check.data)

  task = makeUnsupervisedTask("cluster", data = data, weights = weights,
    blocking = blocking, fixup.data = fixup.data,
    check.data = check.data, coordinates = coordinates)
  task$task.desc = makeClusterTaskDesc(id, data, weights, blocking, coordinates)
  addClasses(task, "ClusterTask")
}

#' @export
#' @rdname makeTaskDesc
makeClusterTaskDesc = function(id, data, weights, blocking, coordinates) {
  target = character(0L)
  td = makeTaskDescInternal("cluster", id, data, target, weights, blocking, coordinates)
  return(addClasses(td, c("ClusterTaskDesc", "UnsupervisedTaskDesc")))
}

#' @export
print.ClusterTask = function(x, ...) {
  print.UnsupervisedTask(x)
}