R/complexity.R
changed.
Other files ignored by Codecov
man/complexity.Rd
has changed.
DESCRIPTION
has changed.
11 | 11 | #' @param features A list of features names or \code{"all"} to include all them. |
|
12 | 12 | #' The supported values are described in the details section. (Default: |
|
13 | 13 | #' \code{"all"}) |
|
14 | + | #' @param summary A list of summarization functions or empty for all values. See |
|
15 | + | #' \link{post.processing} method to more information. (Default: |
|
16 | + | #' \code{c("mean", "sd")}) |
|
14 | 17 | #' @param formula A formula to define the class column. |
|
15 | 18 | #' @param data A data.frame dataset contained the input attributes and class |
|
16 | 19 | #' @param ... Not used. |
75 | 78 | ||
76 | 79 | #' @rdname complexity |
|
77 | 80 | #' @export |
|
78 | - | complexity.default <- function(x, y, features="all", ...) { |
|
81 | + | complexity.default <- function(x, y, features="all", |
|
82 | + | summary=c("mean", "sd"), ...) { |
|
79 | 83 | if(!is.data.frame(x)) { |
|
80 | 84 | stop("data argument must be a data.frame") |
|
81 | 85 | } |
98 | 102 | } |
|
99 | 103 | ||
100 | 104 | if (any(features %in% ls.complexity.groups("class"))) { |
|
101 | - | features <- unique(c(features, unlist(sapply(features, ls.complexity.groups)))) |
|
105 | + | features <- unique(c(features, unlist(sapply(features, |
|
106 | + | ls.complexity.groups)))) |
|
102 | 107 | } |
|
103 | 108 | features <- match.arg(features, ls.complexity(), TRUE) |
|
104 | 109 | colnames(x) <- make.names(colnames(x), unique=TRUE) |
|
105 | 110 | ||
106 | 111 | groups <- names(which(sapply(ls.complexity.groups("class"), |
|
107 | 112 | function(x) any(features %in% ls.complexity.groups(x))))) |
|
108 | - | groups <- gsub("linearity", "linearity.class", groups) |
|
109 | 113 | ||
110 | - | unlist( |
|
111 | - | lapply(groups, function(group) { |
|
112 | - | fmethod <- get(group, asNamespace("ECoL")) |
|
113 | - | measures <- intersect(features, ls.complexity.groups(group)) |
|
114 | - | do.call(fmethod, list(x=x, y=y, measures=measures, summary="return", ...)) |
|
115 | - | }) |
|
116 | - | )[features] |
|
114 | + | do.call(c, lapply(groups, function(group) { |
|
115 | + | fmethod <- get(group, asNamespace("ECoL")) |
|
116 | + | measures <- intersect(features, ls.complexity.groups(group)) |
|
117 | + | subgroups <- do.call(fmethod, list(x=x, y=y, measures=measures, |
|
118 | + | summary="return", ...)) |
|
119 | + | sapply(names(subgroups), function(measure){ |
|
120 | + | post.processing(subgroups[[measure]], summary, |
|
121 | + | measure %in% ls.complexity.multiples(), ...) |
|
122 | + | }, simplify = FALSE) |
|
123 | + | }))[features] |
|
117 | 124 | } |
|
118 | 125 | ||
119 | 126 | #' @rdname complexity |
|
120 | 127 | #' @export |
|
121 | - | complexity.formula <- function(formula, data, features="all", ...) { |
|
128 | + | complexity.formula <- function(formula, data, features="all", |
|
129 | + | summary=c("mean", "sd"), ...) { |
|
122 | 130 | if(!inherits(formula, "formula")) { |
|
123 | 131 | stop("method is only for formula datas") |
|
124 | 132 | } |
130 | 138 | modFrame <- stats::model.frame(formula, data) |
|
131 | 139 | attr(modFrame, "terms") <- NULL |
|
132 | 140 | ||
133 | - | complexity.default(modFrame[-1], modFrame[1], features, ...) |
|
141 | + | complexity.default(modFrame[-1], modFrame[1], features, summary, ...) |
|
134 | 142 | } |
|
135 | 143 | ||
136 | 144 | #' List the complexity meta-features |
145 | 153 | } |
|
146 | 154 | ||
147 | 155 | ls.complexity.multiples <- function() { |
|
148 | - | c() |
|
156 | + | c(c("F1", "F1v", "F2", "F3", "F4"), #overlapping |
|
157 | + | c("N2", "N3", "N4", "T1"), #neighborhood |
|
158 | + | c("L1", "L2", "L3"), #linearity |
|
159 | + | c(), #dimensionality |
|
160 | + | c(), #balance |
|
161 | + | c("Hubs") #network |
|
162 | + | ) |
|
149 | 163 | } |
|
150 | 164 | ||
151 | 165 | ls.complexity.groups <- function(type) { |
|
152 | 166 | ||
153 | 167 | switch(type, |
|
154 | 168 | class = { |
|
155 | - | c("overlapping", "neighborhood", |
|
156 | - | "linearity", "dimensionality", |
|
169 | + | c("overlapping", "neighborhood", "linearity", "dimensionality", |
|
157 | 170 | "balance", "network") |
|
158 | 171 | }, regr = { |
|
159 | 172 | c("correlation", "linearity", |
168 | 181 | linearity = { |
|
169 | 182 | c("L1", "L2", "L3") |
|
170 | 183 | }, |
|
171 | - | linearity.class = { |
|
172 | - | c("L1", "L2", "L3") |
|
173 | - | }, |
|
174 | 184 | dimensionality = { |
|
175 | 185 | c("T2", "T3", "T4") |
|
176 | 186 | }, |
Files | Coverage |
---|---|
R | 90.04% |
Project Totals (13 files) | 90.04% |