3
votes

I got an exercise, where I need to train a linear regression model and get some information about the model:

  • linear relationship between my chosen variable and the other variables
  • which variables are important for the model
  • significance

It´s easy to create an model with the lm-function, so that I can interpret it with summary(mod).

mod <- lm(cars$height ~ ., data = cars)

The summary()-MEthod returns everything: r-squared, coefficients, p-value, significance ...

But when Im training my model like:

library(mlr)

lrn = makeLearner("regr.ksvm")

mod = train(learner = lrn, task = task)

pred = predict(object = mod, newdata = test)

performance(pred = pred, measures = list(mse, arsq))

I´m just getting the mse and r-squareZd. How to get to the other information like significance, important variables ... Is there a hance to get access to this mod?

Thanks for help

1
Please make sure to post a reproducible example next time, your code does not run in its current state.pat-s

1 Answers

4
votes
library(mlr)
#> Loading required package: ParamHelpers
#> 'mlr' is in maintenance mode since July 2019. Future development
#> efforts will go into its successor 'mlr3' (<https://mlr3.mlr-org.com>).

lrn = makeLearner("regr.lm")

mod = train(learner = lrn, task = bh.task)

getLearnerModel(mod)
#> 
#> Call:
#> stats::lm(formula = f, data = d)
#> 
#> Coefficients:
#> (Intercept)         crim           zn        indus        chas1          nox  
#>   3.646e+01   -1.080e-01    4.642e-02    2.056e-02    2.687e+00   -1.777e+01  
#>          rm          age          dis          rad          tax      ptratio  
#>   3.810e+00    6.922e-04   -1.476e+00    3.060e-01   -1.233e-02   -9.527e-01  
#>           b        lstat  
#>   9.312e-03   -5.248e-01

Created on 2020-01-15 by the reprex package (v0.3.0.9001)