You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/generic.jl
+62-43Lines changed: 62 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,13 @@ generic_fit(X,
12
12
)
13
13
```
14
14
15
-
Given a `feature_mapper` (see definition below), this method applies
16
-
`feature_mapper` across a specified subset of categorical columns in X and returns a dictionary
17
-
whose keys are the feature names, and each value is the corresponding
18
-
level‑to‑value mapping produced by `feature_mapper`.
15
+
Given a `feature_mapper` (see definition below), this method applies `feature_mapper`
16
+
across a specified subset of categorical columns in X and returns a dictionary whose keys
17
+
are the feature names, and each value is the corresponding level‑to‑value mapping produced
18
+
by `feature_mapper`.
19
19
20
-
In essence, it spares effort of looping over each column and applying the `feature_mapper` function manually as well as handling the feature selection logic.
20
+
In essence, it spares effort of looping over each column and applying the `feature_mapper`
21
+
function manually as well as handling the feature selection logic.
21
22
22
23
23
24
# Arguments
@@ -26,17 +27,22 @@ $X_doc
26
27
$features_doc
27
28
$ignore_doc
28
29
$ordered_factor_doc
29
-
- feature_mapper: function that, for a given vector (eg, corresponding to a categorical column from the dataset `X`),
30
-
produces a mapping from each category level name in this vector to a scalar or vector according to specified transformation logic.
30
+
31
+
- feature_mapper: function that, for a given vector (eg, corresponding to a categorical
32
+
column from the dataset `X`), produces a mapping from each category level name in this
33
+
vector to a scalar or vector according to specified transformation logic.
31
34
32
35
# Note
33
36
34
-
- Any additional arguments (whether keyword or not) provided to this function are passed to the `feature_mapper` function which
35
-
is helpful when `feature_mapper` requires additional arguments to compute the mapping (eg, hyperparameters).
37
+
- Any additional arguments (whether keyword or not) provided to this function are passed
38
+
to the `feature_mapper` function which is helpful when `feature_mapper` requires
39
+
additional arguments to compute the mapping (eg, hyperparameters).
36
40
37
41
# Returns
38
-
- `mapping_per_feat_level`: Maps each level for each feature in a subset of the categorical features of
39
-
X into a scalar or a vector.
42
+
43
+
- `mapping_per_feat_level`: Maps each level for each feature in a subset of the
44
+
categorical features of X into a scalar or a vector.
45
+
40
46
$encoded_features_doc
41
47
"""
42
48
functiongeneric_fit(X,
@@ -50,11 +56,11 @@ function generic_fit(X,
50
56
# 1. Get X column types and names
51
57
feat_names = Tables.schema(X).names
52
58
53
-
#2. Modify column_names based on features
59
+
#2. Modify column_names based on features
54
60
if features isa Symbol
55
61
features = [features]
56
62
end
57
-
63
+
58
64
if features isa AbstractVector{Symbol}
59
65
# Original behavior for vector of symbols
60
66
feat_names =
@@ -94,8 +100,9 @@ end
94
100
"""
95
101
**Private method.**
96
102
97
-
Function to generate new feature names: feat_name_0, feat_name_1,..., feat_name_n or if possible,
0 commit comments