GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — work on example · WinVector/Examples@c7033c0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • rebalance
    • traj_graph_2.Rmd
    • traj_graph_2.md
    • traj_graph_2_files/figure-gfm
      • unnamed-chunk-5-1.png
      • unnamed-chunk-6-1.png
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎rebalance/traj_graph_2.Rmd‎

Copy file name to clipboardExpand all lines: rebalance/traj_graph_2.Rmd
+2-12Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ d_ex <- wrapr::build_frame(
1515
"x1" , "x2", "y" |
1616
0 , 0 , 0 |
1717
1 , 0 , 1 |
18+
-2 , 0 , 0 |
1819
0 , 2 , 1 |
1920
1 , 2 , 1 |
2021
1 , 1 , 0 )
@@ -30,7 +31,7 @@ is_non_decreasing <- function(x) {all(x == cummax(x))}
3031
```{r}
3132
frames <- list()
3233
suppressWarnings(
33-
for(lambda in seq(0.01, 0.99, length.out = 100)) {
34+
for(lambda in seq(0, 10.0, length.out = 1000)) {
3435
model <- glm(y ~ x1 + x2, family=binomial(), data=d_ex, weights = 1 + lambda * d_ex$y)
3536
preds <- predict(model, type='response', newdata=d_ex)
3637
row_frame <- as.data.frame(t(as.matrix(preds)))
@@ -39,14 +40,11 @@ suppressWarnings(
3940
}
4041
)
4142
frames <- do.call(rbind, frames)
42-
for(col in colnames(frames)) { stopifnot(is_non_decreasing(frames[[col]])) }
4343
plot_dat <- data.frame(data.table::melt(
4444
data.table(frames),
4545
variable.name = 'row',
4646
value.name = 'score',
4747
id.vars='lambda'))
48-
plot_dat['logit(lambda)'] = logit(plot_dat['lambda'])
49-
plot_dat['logit(score)'] = logit(plot_dat['score'])
5048
```
5149

5250

@@ -59,11 +57,3 @@ ggplot(
5957
geom_line()
6058
```
6159

62-
63-
```{r}
64-
ggplot(
65-
data=plot_dat,
66-
mapping=aes(x=`logit(lambda)`, y=`logit(score)`, color=row)
67-
) +
68-
geom_line()
69-
```
Collapse file

‎rebalance/traj_graph_2.md‎

Copy file name to clipboardExpand all lines: rebalance/traj_graph_2.md
+3-14Lines changed: 3 additions & 14 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ d_ex <- wrapr::build_frame(
1919
"x1" , "x2", "y" |
2020
0 , 0 , 0 |
2121
1 , 0 , 1 |
22+
-2 , 0 , 0 |
2223
0 , 2 , 1 |
2324
1 , 2 , 1 |
2425
1 , 1 , 0 )
@@ -30,6 +31,7 @@ knitr::kable(d_ex)
3031
|----:|----:|----:|
3132
| 0 | 0 | 0 |
3233
| 1 | 0 | 1 |
34+
| -2 | 0 | 0 |
3335
| 0 | 2 | 1 |
3436
| 1 | 2 | 1 |
3537
| 1 | 1 | 0 |
@@ -42,7 +44,7 @@ is_non_decreasing <- function(x) {all(x == cummax(x))}
4244
``` r
4345
frames <- list()
4446
suppressWarnings(
45-
for(lambda in seq(0.01, 0.99, length.out = 100)) {
47+
for(lambda in seq(0, 10.0, length.out = 1000)) {
4648
model <- glm(y ~ x1 + x2, family=binomial(), data=d_ex, weights = 1 + lambda * d_ex$y)
4749
preds <- predict(model, type='response', newdata=d_ex)
4850
row_frame <- as.data.frame(t(as.matrix(preds)))
@@ -51,14 +53,11 @@ suppressWarnings(
5153
}
5254
)
5355
frames <- do.call(rbind, frames)
54-
for(col in colnames(frames)) { stopifnot(is_non_decreasing(frames[[col]])) }
5556
plot_dat <- data.frame(data.table::melt(
5657
data.table(frames),
5758
variable.name = 'row',
5859
value.name = 'score',
5960
id.vars='lambda'))
60-
plot_dat['logit(lambda)'] = logit(plot_dat['lambda'])
61-
plot_dat['logit(score)'] = logit(plot_dat['score'])
6261
```
6362

6463
``` r
@@ -70,13 +69,3 @@ ggplot(
7069
```
7170

7271
![](traj_graph_2_files/figure-gfm/unnamed-chunk-5-1.png)<!-- -->
73-
74-
``` r
75-
ggplot(
76-
data=plot_dat,
77-
mapping=aes(x=`logit(lambda)`, y=`logit(score)`, color=row)
78-
) +
79-
geom_line()
80-
```
81-
82-
![](traj_graph_2_files/figure-gfm/unnamed-chunk-6-1.png)<!-- -->
Collapse file

‎rebalance/traj_graph_2_files/figure-gfm/unnamed-chunk-5-1.png‎

Copy file name to clipboard
6.47 KB
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎rebalance/traj_graph_2_files/figure-gfm/unnamed-chunk-6-1.png‎

Copy file name to clipboard
-3.91 KB
  • Display the source diff
  • Display the rich diff
Loading

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.