`library(rtemis)`

` .:rtemis 0.96.1 🌊 aarch64-apple-darwin20 (64-bit)`

`library(rtemis)`

` .:rtemis 0.96.1 🌊 aarch64-apple-darwin20 (64-bit)`

**rtemis** makes extensive use of R6 classes. (Early in development, methods were created for all available class systems - S3, S4, RC, R6 - and R6 was the winner).

The following classes are defined - you don’t need to learn or remember these, they are created automatically, as appropriate:

`rtMod`

: Supervised model class`rtModClass`

: Inherits from`rtMod`

and adds support for classification models`rtModBag`

: Inherits from`rtMod`

and adds support for bagged models`rtMeta`

: Inherits from`rtMod`

and adds support for meta models

`rtModLite`

: A “lite”, bare-bones version of`rtMod`

, used internally in some applications`rtModCV`

: Cross-validated models`rtModCVclass`

: Inherits from`rtModCV`

and adds support for cross-validated classification models

`rtClust`

: Clustering class`rtDecom`

: Decomposition class`rtXDecom`

: Cross-decomposition class`rtMeta`

: Meta model class

One of the advantages of such a class system is that it allows storing both attributes (e.g. data like fitted values) and methods (functions that can be performed on the object, like plotting) in an object. Regular R methods (like predict, summary, etc), known as S3 generics, are fully compatible with the R6 system.

Let’s look at an example object.

```
<- rnormmat(200, 5)
x <- rnorm(5)
w <- x %*% w + rnorm(200)
y <- s_GLM(x, y) mod
```

```
02-23-24 13:56:11 Hello, egenn [s_GLM]
.:Regression Input Summary
Training features: 200 x 5
Training outcome: 200 x 1
Testing features: Not available
Testing outcome: Not available
02-23-24 13:56:11 Training GLM... [s_GLM]
.:GLM Regression Training Summary
MSE = 0.98 (83.22%)
RMSE = 0.99 (59.04%)
MAE = 0.80 (57.64%)
r = 0.91 (p = 1.1e-78)
R sq = 0.83
02-23-24 13:56:11 Completed in 0.01 minutes (Real: 0.40; User: 0.38; System: 0.02) [s_GLM]
```

`class(mod)`

`[1] "rtMod" "R6" `

Let’s look at some of the object attributes Remember, in **rtemis**, `fitted`

refers to the estimated values for the training set and `predicted`

referes to the estimated values for the test set.

`head(mod$fitted)`

`[1] 3.2095573 -2.1730911 -1.6769793 1.4256744 -2.7954300 -0.9197162`

`$error.train mod`

```
MSE = 0.98 (83.22%)
RMSE = 0.99 (59.04%)
MAE = 0.80 (57.64%)
r = 0.91 (p = 1.1e-78)
R sq = 0.83
```

By the way - you notice the error was custom printed.

`class(mod$error.train)`

`[1] "regError" "data.frame"`

It is a simple S3 object of class `regError`

to allow this pretty-printing. You can view the data.frame itself too. In this case, it holds some more information.

`as.data.frame(mod$error.train)`

```
MAE MSE RMSE NRMSE MAE.EXP MAE.RED MSE.EXP
1 0.8006722 0.9765743 0.9882177 0.06136084 1.890015 0.5763674 5.820517
MSE.RED RMSE.EXP RMSE.RED r r.p SSE SSR SST
1 0.8322186 2.412575 0.5903888 0.9122602 1.10187e-78 195.3149 968.7886 1164.103
Rsq stderr
1 0.8322186 0.9882177
```

`$describe() mod`

```
Generalized Linear Model was used for regression.
R-squared was 0.83 (training).
```

`$plot() mod`