catto_mean: Mean encoding

Description Usage Arguments Value Examples

View source: R/aggregate.R

Description

Mean encoding

Usage

1
catto_mean(train, ..., response = NULL, test = NULL, verbose = TRUE)

Arguments

train

The training data, in a data.frame or tibble.

...

The columns to be encoded. If none are specified, then all character and factor columns are encoded.

response

The response variable used to calculate means.

test

The test data, in a data.frame or tibble.

verbose

Should informative messages be printed? Defaults to TRUE.

Value

The encoded dataset in a cattonum_df if no test dataset was provided, and the encoded datasets in a cattonum_df2 otherwise.

Examples

1
catto_mean(iris, response = Sepal.Length)

Example output

cattonum is seeking a new maintainer; please respond if interested: https://github.com/bfgray3/cattonum/issues/40
# A cattonum_df with the following data:
    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1            5.1         3.5          1.4         0.2   5.006
2            4.9         3.0          1.4         0.2   5.006
3            4.7         3.2          1.3         0.2   5.006
4            4.6         3.1          1.5         0.2   5.006
5            5.0         3.6          1.4         0.2   5.006
6            5.4         3.9          1.7         0.4   5.006
7            4.6         3.4          1.4         0.3   5.006
8            5.0         3.4          1.5         0.2   5.006
9            4.4         2.9          1.4         0.2   5.006
10           4.9         3.1          1.5         0.1   5.006
11           5.4         3.7          1.5         0.2   5.006
12           4.8         3.4          1.6         0.2   5.006
13           4.8         3.0          1.4         0.1   5.006
14           4.3         3.0          1.1         0.1   5.006
15           5.8         4.0          1.2         0.2   5.006
16           5.7         4.4          1.5         0.4   5.006
17           5.4         3.9          1.3         0.4   5.006
18           5.1         3.5          1.4         0.3   5.006
19           5.7         3.8          1.7         0.3   5.006
20           5.1         3.8          1.5         0.3   5.006
21           5.4         3.4          1.7         0.2   5.006
22           5.1         3.7          1.5         0.4   5.006
23           4.6         3.6          1.0         0.2   5.006
24           5.1         3.3          1.7         0.5   5.006
25           4.8         3.4          1.9         0.2   5.006
26           5.0         3.0          1.6         0.2   5.006
27           5.0         3.4          1.6         0.4   5.006
28           5.2         3.5          1.5         0.2   5.006
29           5.2         3.4          1.4         0.2   5.006
30           4.7         3.2          1.6         0.2   5.006
31           4.8         3.1          1.6         0.2   5.006
32           5.4         3.4          1.5         0.4   5.006
33           5.2         4.1          1.5         0.1   5.006
34           5.5         4.2          1.4         0.2   5.006
35           4.9         3.1          1.5         0.2   5.006
36           5.0         3.2          1.2         0.2   5.006
37           5.5         3.5          1.3         0.2   5.006
38           4.9         3.6          1.4         0.1   5.006
39           4.4         3.0          1.3         0.2   5.006
40           5.1         3.4          1.5         0.2   5.006
41           5.0         3.5          1.3         0.3   5.006
42           4.5         2.3          1.3         0.3   5.006
43           4.4         3.2          1.3         0.2   5.006
44           5.0         3.5          1.6         0.6   5.006
45           5.1         3.8          1.9         0.4   5.006
46           4.8         3.0          1.4         0.3   5.006
47           5.1         3.8          1.6         0.2   5.006
48           4.6         3.2          1.4         0.2   5.006
49           5.3         3.7          1.5         0.2   5.006
50           5.0         3.3          1.4         0.2   5.006
51           7.0         3.2          4.7         1.4   5.936
52           6.4         3.2          4.5         1.5   5.936
53           6.9         3.1          4.9         1.5   5.936
54           5.5         2.3          4.0         1.3   5.936
55           6.5         2.8          4.6         1.5   5.936
56           5.7         2.8          4.5         1.3   5.936
57           6.3         3.3          4.7         1.6   5.936
58           4.9         2.4          3.3         1.0   5.936
59           6.6         2.9          4.6         1.3   5.936
60           5.2         2.7          3.9         1.4   5.936
61           5.0         2.0          3.5         1.0   5.936
62           5.9         3.0          4.2         1.5   5.936
63           6.0         2.2          4.0         1.0   5.936
64           6.1         2.9          4.7         1.4   5.936
65           5.6         2.9          3.6         1.3   5.936
66           6.7         3.1          4.4         1.4   5.936
67           5.6         3.0          4.5         1.5   5.936
68           5.8         2.7          4.1         1.0   5.936
69           6.2         2.2          4.5         1.5   5.936
70           5.6         2.5          3.9         1.1   5.936
71           5.9         3.2          4.8         1.8   5.936
72           6.1         2.8          4.0         1.3   5.936
73           6.3         2.5          4.9         1.5   5.936
74           6.1         2.8          4.7         1.2   5.936
75           6.4         2.9          4.3         1.3   5.936
76           6.6         3.0          4.4         1.4   5.936
77           6.8         2.8          4.8         1.4   5.936
78           6.7         3.0          5.0         1.7   5.936
79           6.0         2.9          4.5         1.5   5.936
80           5.7         2.6          3.5         1.0   5.936
81           5.5         2.4          3.8         1.1   5.936
82           5.5         2.4          3.7         1.0   5.936
83           5.8         2.7          3.9         1.2   5.936
84           6.0         2.7          5.1         1.6   5.936
85           5.4         3.0          4.5         1.5   5.936
86           6.0         3.4          4.5         1.6   5.936
87           6.7         3.1          4.7         1.5   5.936
88           6.3         2.3          4.4         1.3   5.936
89           5.6         3.0          4.1         1.3   5.936
90           5.5         2.5          4.0         1.3   5.936
91           5.5         2.6          4.4         1.2   5.936
92           6.1         3.0          4.6         1.4   5.936
93           5.8         2.6          4.0         1.2   5.936
94           5.0         2.3          3.3         1.0   5.936
95           5.6         2.7          4.2         1.3   5.936
96           5.7         3.0          4.2         1.2   5.936
97           5.7         2.9          4.2         1.3   5.936
98           6.2         2.9          4.3         1.3   5.936
99           5.1         2.5          3.0         1.1   5.936
100          5.7         2.8          4.1         1.3   5.936
101          6.3         3.3          6.0         2.5   6.588
102          5.8         2.7          5.1         1.9   6.588
103          7.1         3.0          5.9         2.1   6.588
104          6.3         2.9          5.6         1.8   6.588
105          6.5         3.0          5.8         2.2   6.588
106          7.6         3.0          6.6         2.1   6.588
107          4.9         2.5          4.5         1.7   6.588
108          7.3         2.9          6.3         1.8   6.588
109          6.7         2.5          5.8         1.8   6.588
110          7.2         3.6          6.1         2.5   6.588
111          6.5         3.2          5.1         2.0   6.588
112          6.4         2.7          5.3         1.9   6.588
113          6.8         3.0          5.5         2.1   6.588
114          5.7         2.5          5.0         2.0   6.588
115          5.8         2.8          5.1         2.4   6.588
116          6.4         3.2          5.3         2.3   6.588
117          6.5         3.0          5.5         1.8   6.588
118          7.7         3.8          6.7         2.2   6.588
119          7.7         2.6          6.9         2.3   6.588
120          6.0         2.2          5.0         1.5   6.588
121          6.9         3.2          5.7         2.3   6.588
122          5.6         2.8          4.9         2.0   6.588
123          7.7         2.8          6.7         2.0   6.588
124          6.3         2.7          4.9         1.8   6.588
125          6.7         3.3          5.7         2.1   6.588
126          7.2         3.2          6.0         1.8   6.588
127          6.2         2.8          4.8         1.8   6.588
128          6.1         3.0          4.9         1.8   6.588
129          6.4         2.8          5.6         2.1   6.588
130          7.2         3.0          5.8         1.6   6.588
131          7.4         2.8          6.1         1.9   6.588
132          7.9         3.8          6.4         2.0   6.588
133          6.4         2.8          5.6         2.2   6.588
134          6.3         2.8          5.1         1.5   6.588
135          6.1         2.6          5.6         1.4   6.588
136          7.7         3.0          6.1         2.3   6.588
137          6.3         3.4          5.6         2.4   6.588
138          6.4         3.1          5.5         1.8   6.588
139          6.0         3.0          4.8         1.8   6.588
140          6.9         3.1          5.4         2.1   6.588
141          6.7         3.1          5.6         2.4   6.588
142          6.9         3.1          5.1         2.3   6.588
143          5.8         2.7          5.1         1.9   6.588
144          6.8         3.2          5.9         2.3   6.588
145          6.7         3.3          5.7         2.5   6.588
146          6.7         3.0          5.2         2.3   6.588
147          6.3         2.5          5.0         1.9   6.588
148          6.5         3.0          5.2         2.0   6.588
149          6.2         3.4          5.4         2.3   6.588
150          5.9         3.0          5.1         1.8   6.588

cattonum documentation built on July 2, 2020, 2:26 a.m.