3
3
# ------------------------------------------------------------------
4
4
5
5
"""
6
- Scale (; low=0.25, high=0.75)
6
+ LowHigh (; low=0.25, high=0.75)
7
7
8
- Applies the Scale transform to all columns of the table.
9
- The scale transform of the column `x` is defined by `(x .- xl) ./ (xh - xl)`,
8
+ Applies the LowHigh transform to all columns of the table.
9
+ The LowHigh transform of the column `x` is defined by `(x .- xl) ./ (xh - xl)`,
10
10
where `xl = quantile(x, low)` and `xh = quantile(x, high)`.
11
11
12
- Scale (col₁, col₂, ..., colₙ; low=0.25, high=0.75)
13
- Scale ([col₁, col₂, ..., colₙ]; low=0.25, high=0.75)
14
- Scale ((col₁, col₂, ..., colₙ); low=0.25, high=0.75)
12
+ LowHigh (col₁, col₂, ..., colₙ; low=0.25, high=0.75)
13
+ LowHigh ([col₁, col₂, ..., colₙ]; low=0.25, high=0.75)
14
+ LowHigh ((col₁, col₂, ..., colₙ); low=0.25, high=0.75)
15
15
16
- Applies the Scale transform on columns `col₁`, `col₂`, ..., `colₙ`.
16
+ Applies the LowHigh transform on columns `col₁`, `col₂`, ..., `colₙ`.
17
17
18
- Scale (regex; low=0.25, high=0.75)
18
+ LowHigh (regex; low=0.25, high=0.75)
19
19
20
- Applies the Scale transform on columns that match with `regex`.
20
+ Applies the LowHigh transform on columns that match with `regex`.
21
21
22
22
# Examples
23
23
24
24
```julia
25
- Scale ()
26
- Scale (low=0, high=1)
27
- Scale (low=0.3, high=0.7)
28
- Scale (1, 3, 5, low=0, high=1)
29
- Scale ([:a, :c, :e], low=0.3, high=0.7)
30
- Scale (("a", "c", "e"), low=0.25, high=0.75)
31
- Scale (r"[ace]", low=0.3, high=0.7)
25
+ LowHigh ()
26
+ LowHigh (low=0, high=1)
27
+ LowHigh (low=0.3, high=0.7)
28
+ LowHigh (1, 3, 5, low=0, high=1)
29
+ LowHigh ([:a, :c, :e], low=0.3, high=0.7)
30
+ LowHigh (("a", "c", "e"), low=0.25, high=0.75)
31
+ LowHigh (r"[ace]", low=0.3, high=0.7)
32
32
```
33
33
"""
34
- struct Scale {S<: ColumnSelector ,T} <: ColwiseFeatureTransform
34
+ struct LowHigh {S<: ColumnSelector ,T} <: ColwiseFeatureTransform
35
35
selector:: S
36
36
low:: T
37
37
high:: T
38
38
39
- function Scale (selector:: S , low:: T , high:: T ) where {S<: ColumnSelector ,T}
39
+ function LowHigh (selector:: S , low:: T , high:: T ) where {S<: ColumnSelector ,T}
40
40
_assert (0 ≤ low ≤ high ≤ 1 , " invalid quantiles" )
41
41
new {S,T} (selector, low, high)
42
42
end
43
43
end
44
44
45
- Scale (selector:: ColumnSelector , low, high) = Scale (selector, promote (low, high)... )
45
+ LowHigh (selector:: ColumnSelector , low, high) = LowHigh (selector, promote (low, high)... )
46
46
47
- Scale (; low= 0.25 , high= 0.75 ) = Scale (AllSelector (), low, high)
48
- Scale (cols; low= 0.25 , high= 0.75 ) = Scale (selector (cols), low, high)
49
- Scale (cols:: C... ; low= 0.25 , high= 0.75 ) where {C<: Column } = Scale (selector (cols), low, high)
47
+ LowHigh (; low= 0.25 , high= 0.75 ) = LowHigh (AllSelector (), low, high)
48
+ LowHigh (cols; low= 0.25 , high= 0.75 ) = LowHigh (selector (cols), low, high)
49
+ LowHigh (cols:: C... ; low= 0.25 , high= 0.75 ) where {C<: Column } = LowHigh (selector (cols), low, high)
50
50
51
- assertions (transform:: Scale ) = [scitypeassert (Continuous, transform. selector)]
51
+ assertions (transform:: LowHigh ) = [scitypeassert (Continuous, transform. selector)]
52
52
53
- parameters (transform:: Scale ) = (low= transform. low, high= transform. high)
53
+ parameters (transform:: LowHigh ) = (low= transform. low, high= transform. high)
54
54
55
- isrevertible (:: Type{<:Scale } ) = true
55
+ isrevertible (:: Type{<:LowHigh } ) = true
56
56
57
- function colcache (transform:: Scale , x)
57
+ function colcache (transform:: LowHigh , x)
58
58
low = convert (eltype (x), transform. low)
59
59
high = convert (eltype (x), transform. high)
60
60
xl, xh = quantile (x, (low, high))
61
61
xl == xh && ((xl, xh) = (zero (xl), one (xh)))
62
62
(; xl, xh)
63
63
end
64
64
65
- colapply (:: Scale , x, c) = @. (x - c. xl) / (c. xh - c. xl)
65
+ colapply (:: LowHigh , x, c) = @. (x - c. xl) / (c. xh - c. xl)
66
66
67
- colrevert (:: Scale , y, c) = @. (c. xh - c. xl) * y + c. xl
67
+ colrevert (:: LowHigh , y, c) = @. (c. xh - c. xl) * y + c. xl
68
68
69
69
"""
70
70
MinMax()
71
71
72
72
Applies the MinMax transform to all columns of the table.
73
- The MinMax transform is equivalent to `Scale (low=0, high=1)`.
73
+ The MinMax transform is equivalent to `LowHigh (low=0, high=1)`.
74
74
75
75
MinMax(col₁, col₂, ..., colₙ)
76
76
MinMax([col₁, col₂, ..., colₙ])
@@ -91,15 +91,15 @@ MinMax(("a", "c", "e"))
91
91
MinMax(r"[ace]")
92
92
```
93
93
94
- See also [`Scale `](@ref).
94
+ See also [`LowHigh `](@ref).
95
95
"""
96
- MinMax (args... ) = Scale (args... ; low= 0 , high= 1 )
96
+ MinMax (args... ) = LowHigh (args... ; low= 0 , high= 1 )
97
97
98
98
"""
99
99
Interquartile()
100
100
101
101
Applies the Interquartile transform to all columns of the table.
102
- The Interquartile transform is equivalent to `Scale (low=0.25, high=0.75)`.
102
+ The Interquartile transform is equivalent to `LowHigh (low=0.25, high=0.75)`.
103
103
104
104
Interquartile(col₁, col₂, ..., colₙ)
105
105
Interquartile([col₁, col₂, ..., colₙ])
@@ -120,6 +120,6 @@ Interquartile(("a", "c", "e"))
120
120
Interquartile(r"[ace]")
121
121
```
122
122
123
- See also [`Scale `](@ref).
123
+ See also [`LowHigh `](@ref).
124
124
"""
125
- Interquartile (args... ) = Scale (args... ; low= 0.25 , high= 0.75 )
125
+ Interquartile (args... ) = LowHigh (args... ; low= 0.25 , high= 0.75 )
0 commit comments