-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `cmatrix()`-function now accepts the argument `w`, a <numeric>-vector of sample weights. 🚀 * Unit-tests: Updated the unit-tests so it can accomodate weighted metrics * Documentation: Updated documentation on `cmatrix()`-function * NEWS: Updated news. * DESCRIPTION: Version bump! 🚀 All tests passed locally.
- Loading branch information
Showing
14 changed files
with
415 additions
and
45 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
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,61 @@ | ||
# 1) recode Iris | ||
# to binary classification | ||
# problem | ||
iris$species_num <- as.numeric( | ||
iris$Species == "virginica" | ||
) | ||
|
||
# 1.1) set some arbitrary | ||
# weight | ||
iris$weights <- rbeta( | ||
n = nrow(iris), | ||
shape1 = 20, | ||
shape2 = 1 | ||
) | ||
|
||
# 2) fit the logistic | ||
# regression | ||
model <- glm( | ||
formula = species_num ~ Sepal.Length + Sepal.Width, | ||
data = iris, | ||
family = binomial( | ||
link = "logit" | ||
), | ||
weights = iris$weights | ||
) | ||
|
||
# 3) generate predicted | ||
# classes | ||
predicted <- factor( | ||
as.numeric( | ||
predict(model, type = "response") > 0.5 | ||
), | ||
levels = c(1,0), | ||
labels = c("Virginica", "Others") | ||
) | ||
|
||
# 3.1) generate actual | ||
# classes | ||
actual <- factor( | ||
x = iris$species_num, | ||
levels = c(1,0), | ||
labels = c("Virginica", "Others") | ||
) | ||
|
||
# 4) confusion matrix | ||
confusion_matrix <- cmatrix( | ||
actual = actual, | ||
predicted = predicted, | ||
w = iris$weights | ||
) | ||
|
||
# 4.1) summarise matrix | ||
summary( | ||
confusion_matrix | ||
) | ||
|
||
# 4.2) plot confusion | ||
# matrix | ||
plot( | ||
confusion_matrix | ||
) |
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
Oops, something went wrong.