Skip to content

Commit 662ab15

Browse files
committed
Refactored Source Code 📚
* All code has been refactored using Clion. The src-folder should now be easy to navigate in.
1 parent aa3926a commit 662ab15

File tree

55 files changed

+298
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+298
-387
lines changed

.Rbuildignore

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
^codemeta
1616
^[^/]+\.R$
1717
Makefile
18+
src/CMakeLists.txt
19+
src/cmake-build-debug
20+
src/.idea

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ rsconnect/
5353
playground/
5454
docs
5555
inst/doc
56+
57+
58+
# Clion Files
59+
src/CMakeLists.txt
60+
src/cmake-build-debug
61+
src/.idea

R/RcppExports.R

+64-64
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

4-
#' @rdname fmi
5-
#' @method fmi factor
6-
#' @export
7-
fmi.factor <- function(actual, predicted, ...) {
8-
.Call(`_SLmetrics_fmi`, actual, predicted)
9-
}
10-
11-
#' @rdname fmi
12-
#' @method fmi cmatrix
13-
#' @export
14-
fmi.cmatrix <- function(x, ...) {
15-
.Call(`_SLmetrics_fmi_cmatrix`, x)
16-
}
17-
184
#' @rdname accuracy
195
#' @method accuracy factor
206
#'
@@ -47,6 +33,22 @@ baccuracy.cmatrix <- function(x, adjust = FALSE, ...) {
4733
.Call(`_SLmetrics_baccuracy_cmatrix`, x, adjust)
4834
}
4935

36+
#' @rdname ckappa
37+
#' @method ckappa factor
38+
#'
39+
#' @export
40+
ckappa.factor <- function(actual, predicted, beta = 1.0, ...) {
41+
.Call(`_SLmetrics_ckappa`, actual, predicted, beta)
42+
}
43+
44+
#' @rdname ckappa
45+
#' @method ckappa cmatrix
46+
#'
47+
#' @export
48+
ckappa.cmatrix <- function(x, beta = 1.0, ...) {
49+
.Call(`_SLmetrics_ckappa_cmatrix`, x, beta)
50+
}
51+
5052
#' Confusion Matrix
5153
#'
5254
#' @description
@@ -185,6 +187,20 @@ fallout.cmatrix <- function(x, micro = NULL, na.rm = TRUE, ...) {
185187
.Call(`_SLmetrics_fallout_cmatrix`, x, micro, na_rm = na.rm)
186188
}
187189

190+
#' @rdname fmi
191+
#' @method fmi factor
192+
#' @export
193+
fmi.factor <- function(actual, predicted, ...) {
194+
.Call(`_SLmetrics_fmi`, actual, predicted)
195+
}
196+
197+
#' @rdname fmi
198+
#' @method fmi cmatrix
199+
#' @export
200+
fmi.cmatrix <- function(x, ...) {
201+
.Call(`_SLmetrics_fmi_cmatrix`, x)
202+
}
203+
188204
#' @rdname jaccard
189205
#' @method jaccard factor
190206
#' @export
@@ -227,22 +243,6 @@ tscore.cmatrix <- function(x, micro = NULL, na.rm = TRUE, ...) {
227243
.Call(`_SLmetrics_tscore_cmatrix`, x, micro, na_rm = na.rm)
228244
}
229245

230-
#' @rdname ckappa
231-
#' @method ckappa factor
232-
#'
233-
#' @export
234-
ckappa.factor <- function(actual, predicted, beta = 1.0, ...) {
235-
.Call(`_SLmetrics_ckappa`, actual, predicted, beta)
236-
}
237-
238-
#' @rdname ckappa
239-
#' @method ckappa cmatrix
240-
#'
241-
#' @export
242-
ckappa.cmatrix <- function(x, beta = 1.0, ...) {
243-
.Call(`_SLmetrics_ckappa_cmatrix`, x, beta)
244-
}
245-
246246
#' @rdname mcc
247247
#' @method mcc factor
248248
#' @export
@@ -461,6 +461,40 @@ zerooneloss.cmatrix <- function(x, ...) {
461461
.Call(`_SLmetrics_zerooneloss_cmatrix`, x)
462462
}
463463

464+
#' Compute the \eqn{R^2}
465+
#'
466+
#' @description
467+
#' The [rsq()]-function calculates the \eqn{R^2}, the [coefficient of determination](https://en.wikipedia.org/wiki/Coefficient_of_determination), between the ovserved
468+
#' and predicted <[numeric]> vectors. By default [rsq()] returns the unadjusted \eqn{R^2}. For adjusted \eqn{R^2} set \eqn{k = \kappa - 1}, where \eqn{\kappa} is the number of parameters.
469+
#'
470+
#' @usage
471+
#' # `rsq()`-function
472+
#' rsq(
473+
#' actual,
474+
#' predicted,
475+
#' k = 0
476+
#' )
477+
#'
478+
#' @inherit huberloss
479+
#' @param k A <[numeric]>-vector of [length] 1. 0 by default. If \eqn{k>0}
480+
#' the function returns the adjusted \eqn{R^2}.
481+
#'
482+
#' @section Calculation:
483+
#'
484+
#' The metric is calculated as follows,
485+
#'
486+
#' \deqn{
487+
#' R^2 = 1 - \frac{\text{SSE}}{\text{SST}} \frac{n-1}{n - (k + 1)}
488+
#' }
489+
#'
490+
#' Where \eqn{\text{SSE}} is the sum of squared errors, \eqn{\text{SST}} is total sum of squared errors, \eqn{n} is the number of observations, and \eqn{k} is the number of non-constant parameters.
491+
#'
492+
#' @family regression
493+
#'
494+
rsq <- function(actual, predicted, k = 0) {
495+
.Call(`_SLmetrics_rsq`, actual, predicted, k)
496+
}
497+
464498
#' Compute the \eqn{\text{concordance correlation coefficient}}
465499
#'
466500
#' @description
@@ -856,40 +890,6 @@ wrmsle <- function(actual, predicted, w) {
856890
.Call(`_SLmetrics_wrmsle`, actual, predicted, w)
857891
}
858892

859-
#' Compute the \eqn{R^2}
860-
#'
861-
#' @description
862-
#' The [rsq()]-function calculates the \eqn{R^2}, the [coefficient of determination](https://en.wikipedia.org/wiki/Coefficient_of_determination), between the ovserved
863-
#' and predicted <[numeric]> vectors. By default [rsq()] returns the unadjusted \eqn{R^2}. For adjusted \eqn{R^2} set \eqn{k = \kappa - 1}, where \eqn{\kappa} is the number of parameters.
864-
#'
865-
#' @usage
866-
#' # `rsq()`-function
867-
#' rsq(
868-
#' actual,
869-
#' predicted,
870-
#' k = 0
871-
#' )
872-
#'
873-
#' @inherit huberloss
874-
#' @param k A <[numeric]>-vector of [length] 1. 0 by default. If \eqn{k>0}
875-
#' the function returns the adjusted \eqn{R^2}.
876-
#'
877-
#' @section Calculation:
878-
#'
879-
#' The metric is calculated as follows,
880-
#'
881-
#' \deqn{
882-
#' R^2 = 1 - \frac{\text{SSE}}{\text{SST}} \frac{n-1}{n - (k + 1)}
883-
#' }
884-
#'
885-
#' Where \eqn{\text{SSE}} is the sum of squared errors, \eqn{\text{SST}} is total sum of squared errors, \eqn{n} is the number of observations, and \eqn{k} is the number of non-constant parameters.
886-
#'
887-
#' @family regression
888-
#'
889-
rsq <- function(actual, predicted, k = 0) {
890-
.Call(`_SLmetrics_rsq`, actual, predicted, k)
891-
}
892-
893893
#' Compute the \eqn{\text{symmetric mean absolute percentage error}}
894894
#'
895895
#' The [smape()]- and [wsmape()]-function computes the simple and weighted [symmetric mean absolute percentage error](https://en.wikipedia.org/wiki/Symmetric_mean_absolute_percentage_error).

src/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
*.o
22
*.so
33
*.dll
4+
CMakeLists.txt
5+
cmake-build-debug
6+
.idea/

0 commit comments

Comments
 (0)