Add polynomial regression learner#589
Conversation
|
@tdhock Could you please review this polynomial regression learner? Thank you! |
|
@tdhock Pouvez vous vérifier ça svp ? |
|
Hi @imanechadli2003 can you please add a comment here with the code and result figure for a benchmark that shows your learner with baselines? (featureless, cv_glmnet, nearest neighbors) |
|
@tdhock Hi! Here is the benchmark code and result figure comparing Codelibrary(mlr3)
library(mlr3learners)
library(mlr3tuning)
library(mlr3extralearners)
library(ggplot2)
tasks = list(
tsk("mtcars"),
as_task_regr(airquality[complete.cases(airquality),],
target = "Ozone", id = "airquality")
)
lrn_poly = lrn("regr.polynomial", degree = 2L)
lrn_poly$id = "poly_regr"
lrn_knn = auto_tuner(
tuner = tnr("grid_search", resolution = 10),
learner = lrn("regr.kknn", k = to_tune(1L, 10L)),
resampling = rsmp("cv", folds = 3),
measure = msr("regr.mse")
)
lrn_knn$id = "kknn_tuned"
design = benchmark_grid(
tasks = tasks,
learners = list(lrn_poly, lrn("regr.featureless"),
lrn("regr.cv_glmnet"), lrn_knn),
resamplings = rsmp("cv", folds = 5)
)
bmr = benchmark(design)
results = bmr$score(msr("regr.mse"))
ggplot(results, aes(x = regr.mse, y = learner_id)) +
geom_point() +
facet_grid(task_id ~ ., scales = "free_x") +
labs(x = "MSE", y = "Learner")Result
|
|
poly_reg is worse than featureless in mtcars? |
|
@tdhock Hi , here is the updated benchmark with:
poly_tuned is now better than featureless on both datasets. |
|
can you please edit the first comment of the PR, add "Closes #420" to indicate that merging this PR provides the functionality asked for in that issue? remotes::install_github("imanechadli2003/mlr3extralearners@polynomial-regression-learner")can you please convert this PR from draft to regular PR to indicate that it is ready for review? |


Summary
This PR adds a polynomial regression learner for mlr3extralearners.
regr.polynomialstats(base R), usingstats::lm()withstats::poly()degree(integer, default = 2): degree of the polynomialraw(logical, default = FALSE): whether to use raw polynomialsFiles added
R/learner_stats_regr_polynomial.Rtests/testthat/test_stats_regr_polynomial.Rtests/testthat/test_paramtest_stats_regr_polynomial.R