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
# adapted from https://towardsdatascience.com/simple-trick-to-train-an-ordinal-regression-with-any-classifier-6911183d2a3c | |
class OrdinalClassifier: | |
def __init__(self, clf): | |
self.clf = clf | |
self.clfs = {} | |
def fit(self, X, y): | |
self.classes_ = np.sort(np.unique(y)) | |
if self.classes_.shape[0] > 2: | |
for level in self.classes_[: (self.classes_.shape[0] - 1)]: |
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
library(styler) | |
guide <- tidyverse_style(scope = "line_breaks", indent_by = 8) | |
guide_with_indention_rules_only <- purrr::modify_at( | |
guide, 3, ~.x[grepl("indent", names(.x))] | |
) | |
styler::style_text( | |
"call( | |
x = 2 | |
) | |
a =3 |
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
``` r | |
string_formula <- paste0(names(mtcars)[1], " ~", paste0(names(mtcars)[-1], collapse = "+")) | |
lm(as.formula(string_formula), data = mtcars) | |
#> | |
#> Call: | |
#> lm(formula = as.formula(string_formula), data = mtcars) | |
#> | |
#> Coefficients: | |
#> (Intercept) cyl disp hp drat |
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
``` r | |
# with a formula | |
fit_something <- function(data, formula, ...) { | |
lm(as.formula(formula), data = data, ...) | |
} | |
fit_something(mtcars, "cyl ~mpg") | |
#> | |
#> Call: | |
#> lm(formula = as.formula(formula), data = data) |
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
# ____________________________________________________________________________ | |
# function test #### | |
test <- function(x) { | |
## ............................................................................ | |
## A: pre-processing #### | |
### .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
### a: assertive tests #### | |
# x | |
if(missing(x) || is.null(x)){ | |
x <- character() |
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
devtools::install_github("lorenzwalthert/strcode") |
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
Summarized structure of ~/Documents/short-term back-up/sum_str.R | |
line level section | |
1 # ________________________________________________________ | |
2 # A title | |
8 ## ........................................................ | |
9 ## A subtitle | |
15 ### . . . . . . . . . . . . . . . . . . . . . . . . . . . .. | |
16 ### Another one |
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
#< 56f5139874167f4f5635b42c37fd6594 ># | |
this_is_a_super_important_but_hard_to_describe_line_so_let_me_anchor_it |
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
## ........ #< bdd0351ff9987e58fec1e1d3dbcdd8d1 ># ........ | |
## An anchored section #### |
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
# ________________________________________________________ | |
# A title #### | |
# this is a level 1 section. l1 sections are are high-level | |
# blocks. | |
# [your code here] | |
## ........................................................ | |
## A sub title #### | |
# this is a level 2 section. These sections are medium-level |
NewerOlder