Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add alevels, tests, examples, version++ #30

Merged
merged 3 commits into from
Mar 25, 2025
Merged

add alevels, tests, examples, version++ #30

merged 3 commits into from
Mar 25, 2025

Conversation

tdhock
Copy link
Owner

@tdhock tdhock commented Mar 24, 2025

> ichr <- nc::capture_melt_single(
+ iris[1,],
+ part="Sepal|Petal",
+ "[.]",
+ dim="Length|Width")
> factor(ichr$part)#default factor levels are alphabetical.
[1] Sepal Sepal Petal Petal
Levels: Petal Sepal
> (ifac <- nc::capture_melt_single(
+ iris[1,],
+ part=nc::alevels("Sepal","Petal"),
+ "[.]",
+ dim=nc::alevels("Length","Width")))
   Species   part    dim value
    <fctr> <fctr> <fctr> <num>
1:  setosa  Sepal Length   5.1
2:  setosa  Sepal  Width   3.5
3:  setosa  Petal Length   1.4
4:  setosa  Petal  Width   0.2
> ifac$part #factor with levels in same order as given in alevels().
[1] Sepal Sepal Petal Petal
Levels: Sepal Petal
> tv_wide <- data.frame(
+ id=0,
+ train.classif.logloss = 1, train.classif.ce = 2,
+ valid.classif.logloss = 3, valid.classif.ce = 4)
> nc::capture_melt_single(
+ tv_wide,
+ set=nc::alevels(valid="validation", train="subtrain"),
+ "[.]classif[.]",
+ measure=nc::alevels(ce="error_prop", auc="AUC", "logloss"))
      id        set    measure value
   <num>     <fctr>     <fctr> <num>
1:     0   subtrain    logloss     1
2:     0   subtrain error_prop     2
3:     0 validation    logloss     3
4:     0 validation error_prop     4
> nc::capture_melt_single(
+ tv_wide,
+ set_chr=list(set_fac=nc::alevels(valid="validation", train="subtrain")),
+ "[.]classif[.]",
+ measure_chr=list(measure_fac=nc::alevels(ce="error_prop", auc="AUC", "logloss")))
      id set_chr    set_fac measure_chr measure_fac value
   <num>  <char>     <fctr>      <char>      <fctr> <num>
1:     0   train   subtrain     logloss     logloss     1
2:     0   train   subtrain          ce  error_prop     2
3:     0   valid validation     logloss     logloss     3
4:     0   valid validation          ce  error_prop     4

@tdhock tdhock merged commit c6cd10e into master Mar 25, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant