Skip to content

Commit 77c3e49

Browse files
authored
Merge pull request #47 from tidymodels/RC-0-3-1
RC 0.3.1
2 parents e93e402 + 080ae88 commit 77c3e49

File tree

10 files changed

+103
-58
lines changed

10 files changed

+103
-58
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: modeldb
22
Title: Fits Models Inside the Database
3-
Version: 0.3.0.9000
3+
Version: 0.3.1
44
Authors@R: c(
55
person("Edgar", "Ruiz", , "[email protected]", role = "aut"),
66
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre"))
@@ -38,4 +38,4 @@ Config/Needs/website: tidyverse/tidytemplate
3838
Config/testthat/edition: 3
3939
Encoding: UTF-8
4040
Roxygen: list(markdown = TRUE)
41-
RoxygenNote: 7.2.3
41+
RoxygenNote: 7.3.2

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# modeldb (development version)
1+
# modeldb 0.3.1
2+
3+
- Fixes compatability issues with `ggplot2`
24

35
# modeldb 0.3.0
46

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ dbplyr::remote_query(km)
7979

8080
This project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
8181

82-
- For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on Posit Community](https://community.rstudio.com/new-topic?category_id=15&tags=tidymodels,question).
82+
- For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on Posit Community](https://forum.posit.co/new-topic?category_id=15&tags=tidymodels,question).
8383

8484
- If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/modeldb/issues).
8585

README.md

Lines changed: 90 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ back-ends** because it leverages [dplyr](https://dplyr.tidyverse.org/)
1212
and [dbplyr](https://dbplyr.tidyverse.org/) for the final SQL
1313
translation of the algorithm. It currently supports:
1414

15-
- K-means clustering
15+
- K-means clustering
1616

17-
- Linear regression
17+
- Linear regression
1818

1919
## Installation
2020

@@ -66,8 +66,8 @@ To use the `simple_kmeans_db()` function, simply pipe the database back
6666
end table to the function. This returns a list object that contains two
6767
items:
6868

69-
- A sql query table with the final center assignment
70-
- A local table with the information about the centers
69+
- A sql query table with the final center assignment
70+
- A local table with the information about the centers
7171

7272
``` r
7373
km <- tbl(con, "mtcars") %>%
@@ -87,52 +87,101 @@ The SQL statement from `tbl` can be extracted using dbplyr’s
8787
dbplyr::remote_query(km)
8888
```
8989

90-
## <SQL> SELECT `k_center`, `k_mpg`, `k_wt`, `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`
91-
## FROM (SELECT `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`, `LHS`.`k_center` AS `k_center`, `k_mpg`, `k_wt`
92-
## FROM (SELECT `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`, `center` AS `k_center`
93-
## FROM (SELECT `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`, `center_1`, `center_2`, `center_3`, CASE
94-
## WHEN (`center_1` >= `center_1` AND `center_1` < `center_2` AND `center_1` < `center_3`) THEN ('center_1')
95-
## WHEN (`center_2` < `center_1` AND `center_2` >= `center_2` AND `center_2` < `center_3`) THEN ('center_2')
96-
## WHEN (`center_3` < `center_1` AND `center_3` < `center_2` AND `center_3` >= `center_3`) THEN ('center_3')
90+
## <SQL> SELECT
91+
## `LHS`.`k_center` AS `k_center`,
92+
## `k_mpg`,
93+
## `k_wt`,
94+
## `mpg`,
95+
## `cyl`,
96+
## `disp`,
97+
## `hp`,
98+
## `drat`,
99+
## `wt`,
100+
## `qsec`,
101+
## `vs`,
102+
## `am`,
103+
## `gear`,
104+
## `carb`
105+
## FROM (
106+
## SELECT
107+
## `mpg`,
108+
## `cyl`,
109+
## `disp`,
110+
## `hp`,
111+
## `drat`,
112+
## `wt`,
113+
## `qsec`,
114+
## `vs`,
115+
## `am`,
116+
## `gear`,
117+
## `carb`,
118+
## `center` AS `k_center`
119+
## FROM (
120+
## SELECT
121+
## `q01`.*,
122+
## CASE
123+
## WHEN (`center_1` >= `center_1` AND `center_1` < `center_2` AND `center_1` < `center_3`) THEN 'center_1'
124+
## WHEN (`center_2` < `center_1` AND `center_2` >= `center_2` AND `center_2` < `center_3`) THEN 'center_2'
125+
## WHEN (`center_3` < `center_1` AND `center_3` < `center_2` AND `center_3` >= `center_3`) THEN 'center_3'
97126
## END AS `center`
98-
## FROM (SELECT `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`, SQRT(((20.6428571428571 - `mpg`) * (20.6428571428571 - `mpg`)) + ((3.07214285714286 - `wt`) * (3.07214285714286 - `wt`))) AS `center_1`, SQRT(((14.4583333333333 - `mpg`) * (14.4583333333333 - `mpg`)) + ((4.05866666666667 - `wt`) * (4.05866666666667 - `wt`))) AS `center_2`, SQRT(((30.0666666666667 - `mpg`) * (30.0666666666667 - `mpg`)) + ((1.873 - `wt`) * (1.873 - `wt`))) AS `center_3`
99-
## FROM `mtcars`))
100-
## WHERE (NOT(((`center`) IS NULL)))) AS `LHS`
101-
## LEFT JOIN (SELECT `center` AS `k_center`, `mpg` AS `k_mpg`, `wt` AS `k_wt`
102-
## FROM (SELECT `center`, AVG(`mpg`) AS `mpg`, AVG(`wt`) AS `wt`
103-
## FROM (SELECT `mpg`, `wt`, `center`
104-
## FROM (SELECT `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`, `center_1`, `center_2`, `center_3`, CASE
105-
## WHEN (`center_1` >= `center_1` AND `center_1` < `center_2` AND `center_1` < `center_3`) THEN ('center_1')
106-
## WHEN (`center_2` < `center_1` AND `center_2` >= `center_2` AND `center_2` < `center_3`) THEN ('center_2')
107-
## WHEN (`center_3` < `center_1` AND `center_3` < `center_2` AND `center_3` >= `center_3`) THEN ('center_3')
127+
## FROM (
128+
## SELECT
129+
## `mtcars`.*,
130+
## SQRT(((20.6428571428571 - `mpg`) * (20.6428571428571 - `mpg`)) + ((3.07214285714286 - `wt`) * (3.07214285714286 - `wt`))) AS `center_1`,
131+
## SQRT(((14.4583333333333 - `mpg`) * (14.4583333333333 - `mpg`)) + ((4.05866666666667 - `wt`) * (4.05866666666667 - `wt`))) AS `center_2`,
132+
## SQRT(((30.0666666666667 - `mpg`) * (30.0666666666667 - `mpg`)) + ((1.873 - `wt`) * (1.873 - `wt`))) AS `center_3`
133+
## FROM `mtcars`
134+
## ) AS `q01`
135+
## ) AS `q01`
136+
## WHERE (NOT((`center` IS NULL)))
137+
## ) AS `LHS`
138+
## LEFT JOIN (
139+
## SELECT `center` AS `k_center`, AVG(`mpg`) AS `k_mpg`, AVG(`wt`) AS `k_wt`
140+
## FROM (
141+
## SELECT `mpg`, `wt`, `center`
142+
## FROM (
143+
## SELECT
144+
## `q01`.*,
145+
## CASE
146+
## WHEN (`center_1` >= `center_1` AND `center_1` < `center_2` AND `center_1` < `center_3`) THEN 'center_1'
147+
## WHEN (`center_2` < `center_1` AND `center_2` >= `center_2` AND `center_2` < `center_3`) THEN 'center_2'
148+
## WHEN (`center_3` < `center_1` AND `center_3` < `center_2` AND `center_3` >= `center_3`) THEN 'center_3'
108149
## END AS `center`
109-
## FROM (SELECT `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb`, SQRT(((20.6428571428571 - `mpg`) * (20.6428571428571 - `mpg`)) + ((3.07214285714286 - `wt`) * (3.07214285714286 - `wt`))) AS `center_1`, SQRT(((14.4583333333333 - `mpg`) * (14.4583333333333 - `mpg`)) + ((4.05866666666667 - `wt`) * (4.05866666666667 - `wt`))) AS `center_2`, SQRT(((30.0666666666667 - `mpg`) * (30.0666666666667 - `mpg`)) + ((1.873 - `wt`) * (1.873 - `wt`))) AS `center_3`
110-
## FROM `mtcars`))
111-
## WHERE (NOT(((`center`) IS NULL))))
112-
## GROUP BY `center`)) AS `RHS`
113-
## ON (`LHS`.`k_center` = `RHS`.`k_center`)
114-
## )
150+
## FROM (
151+
## SELECT
152+
## `mtcars`.*,
153+
## SQRT(((20.6428571428571 - `mpg`) * (20.6428571428571 - `mpg`)) + ((3.07214285714286 - `wt`) * (3.07214285714286 - `wt`))) AS `center_1`,
154+
## SQRT(((14.4583333333333 - `mpg`) * (14.4583333333333 - `mpg`)) + ((4.05866666666667 - `wt`) * (4.05866666666667 - `wt`))) AS `center_2`,
155+
## SQRT(((30.0666666666667 - `mpg`) * (30.0666666666667 - `mpg`)) + ((1.873 - `wt`) * (1.873 - `wt`))) AS `center_3`
156+
## FROM `mtcars`
157+
## ) AS `q01`
158+
## ) AS `q01`
159+
## WHERE (NOT((`center` IS NULL)))
160+
## ) AS `q01`
161+
## GROUP BY `center`
162+
## ) AS `RHS`
163+
## ON (`LHS`.`k_center` = `RHS`.`k_center`)
115164

116165
## Contributing
117166

118167
This project is released with a [Contributor Code of
119168
Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
120169
By contributing to this project, you agree to abide by its terms.
121170

122-
- For questions and discussions about tidymodels packages, modeling,
123-
and machine learning, please [post on Posit
124-
Community](https://community.rstudio.com/new-topic?category_id=15&tags=tidymodels,question).
171+
- For questions and discussions about tidymodels packages, modeling, and
172+
machine learning, please [post on Posit
173+
Community](https://forum.posit.co/new-topic?category_id=15&tags=tidymodels,question).
125174

126-
- If you think you have encountered a bug, please [submit an
127-
issue](https://github.com/tidymodels/modeldb/issues).
175+
- If you think you have encountered a bug, please [submit an
176+
issue](https://github.com/tidymodels/modeldb/issues).
128177

129-
- Either way, learn how to create and share a
130-
[reprex](https://reprex.tidyverse.org/articles/articles/learn-reprex.html)
131-
(a minimal, reproducible example), to clearly communicate about your
132-
code. Check out [this helpful article on how to create
133-
reprexes](https://dbplyr.tidyverse.org/articles/reprex.html) for
134-
problems involving a database.
178+
- Either way, learn how to create and share a
179+
[reprex](https://reprex.tidyverse.org/articles/articles/learn-reprex.html)
180+
(a minimal, reproducible example), to clearly communicate about your
181+
code. Check out [this helpful article on how to create
182+
reprexes](https://dbplyr.tidyverse.org/articles/reprex.html) for
183+
problems involving a database.
135184

136-
- Check out further details on [contributing guidelines for tidymodels
137-
packages](https://www.tidymodels.org/contribute/) and [how to get
138-
help](https://www.tidymodels.org/help/).
185+
- Check out further details on [contributing guidelines for tidymodels
186+
packages](https://www.tidymodels.org/contribute/) and [how to get
187+
help](https://www.tidymodels.org/help/).

man/modeldb-package.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-as-parsed-model.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("parsed model")
2-
31
test_that("Simple linear regression matches lm()", {
42
expect_is(
53
as_parsed_model(

tests/testthat/test_dummy_var.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("add_dummy_variables")
2-
31
test_that("Function create the correct columns", {
42
cols_expected <- c("mpg", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb", "cyl_6", "cyl_8")
53
expect_equal(

tests/testthat/test_kmeans.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("kmeans")
2-
31
test_that("Specifying variables works", {
42
expect_is(
53
simple_kmeans_db(mtcars, wt, mpg),

tests/testthat/test_kmeans_viz.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
context("kmeans_viz")
2-
31

42
test_that("plot_kmeans() returns a ggplot2 object", {
5-
expect_equal(
6-
class(plot_kmeans(mtcars, mpg, wt, group = am)),
7-
c("gg", "ggplot")
3+
expect_true(
4+
inherits(plot_kmeans(mtcars, mpg, wt, group = am), "ggplot")
85
)
96
})
107

tests/testthat/test_lr.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("Linear Regression")
2-
31
test_that("Simple linear regression matches lm()", {
42
expect_equal(
53
lm(wt ~ mpg, data = mtcars) %>%

0 commit comments

Comments
 (0)