Skip to content

Commit f6a72df

Browse files
committed
Rename Scale --> LowHigh
1 parent b54d69a commit f6a72df

File tree

9 files changed

+67
-67
lines changed

9 files changed

+67
-67
lines changed

docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ are concatenated horizontally in the final table:
9090
```@example usage
9191
# create a transform pipeline
9292
f1 = ZScore()
93-
f2 = Scale()
93+
f2 = LowHigh()
9494
f3 = Quantile()
9595
f4 = Functional(cos)
9696
f5 = Interquartile()

docs/src/transforms.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ Identity
164164
Center
165165
```
166166

167-
## Scale
167+
## LowHigh
168168

169169
```@docs
170-
Scale
170+
LowHigh
171171
```
172172

173173
## MinMax

src/TableTransforms.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export
7575
OneHot,
7676
Identity,
7777
Center,
78-
Scale,
78+
LowHigh,
7979
MinMax,
8080
Interquartile,
8181
ZScore,

src/transforms/parallel.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ revertible transform in the list.
1414
# Examples
1515
1616
```julia
17-
Scale(low=0.3, high=0.6) ⊔ EigenAnalysis(:VDV)
17+
LowHigh(low=0.3, high=0.6) ⊔ EigenAnalysis(:VDV)
1818
ZScore() ⊔ EigenAnalysis(:V)
1919
```
2020

src/transforms/scale.jl

+34-34
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,74 @@
33
# ------------------------------------------------------------------
44

55
"""
6-
Scale(; low=0.25, high=0.75)
6+
LowHigh(; low=0.25, high=0.75)
77
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)`,
1010
where `xl = quantile(x, low)` and `xh = quantile(x, high)`.
1111
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)
1515
16-
Applies the Scale transform on columns `col₁`, `col₂`, ..., `colₙ`.
16+
Applies the LowHigh transform on columns `col₁`, `col₂`, ..., `colₙ`.
1717
18-
Scale(regex; low=0.25, high=0.75)
18+
LowHigh(regex; low=0.25, high=0.75)
1919
20-
Applies the Scale transform on columns that match with `regex`.
20+
Applies the LowHigh transform on columns that match with `regex`.
2121
2222
# Examples
2323
2424
```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)
3232
```
3333
"""
34-
struct Scale{S<:ColumnSelector,T} <: ColwiseFeatureTransform
34+
struct LowHigh{S<:ColumnSelector,T} <: ColwiseFeatureTransform
3535
selector::S
3636
low::T
3737
high::T
3838

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}
4040
_assert(0 low high 1, "invalid quantiles")
4141
new{S,T}(selector, low, high)
4242
end
4343
end
4444

45-
Scale(selector::ColumnSelector, low, high) = Scale(selector, promote(low, high)...)
45+
LowHigh(selector::ColumnSelector, low, high) = LowHigh(selector, promote(low, high)...)
4646

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)
5050

51-
assertions(transform::Scale) = [scitypeassert(Continuous, transform.selector)]
51+
assertions(transform::LowHigh) = [scitypeassert(Continuous, transform.selector)]
5252

53-
parameters(transform::Scale) = (low=transform.low, high=transform.high)
53+
parameters(transform::LowHigh) = (low=transform.low, high=transform.high)
5454

55-
isrevertible(::Type{<:Scale}) = true
55+
isrevertible(::Type{<:LowHigh}) = true
5656

57-
function colcache(transform::Scale, x)
57+
function colcache(transform::LowHigh, x)
5858
low = convert(eltype(x), transform.low)
5959
high = convert(eltype(x), transform.high)
6060
xl, xh = quantile(x, (low, high))
6161
xl == xh && ((xl, xh) = (zero(xl), one(xh)))
6262
(; xl, xh)
6363
end
6464

65-
colapply(::Scale, x, c) = @. (x - c.xl) / (c.xh - c.xl)
65+
colapply(::LowHigh, x, c) = @. (x - c.xl) / (c.xh - c.xl)
6666

67-
colrevert(::Scale, y, c) = @. (c.xh - c.xl) * y + c.xl
67+
colrevert(::LowHigh, y, c) = @. (c.xh - c.xl) * y + c.xl
6868

6969
"""
7070
MinMax()
7171
7272
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)`.
7474
7575
MinMax(col₁, col₂, ..., colₙ)
7676
MinMax([col₁, col₂, ..., colₙ])
@@ -91,15 +91,15 @@ MinMax(("a", "c", "e"))
9191
MinMax(r"[ace]")
9292
```
9393
94-
See also [`Scale`](@ref).
94+
See also [`LowHigh`](@ref).
9595
"""
96-
MinMax(args...) = Scale(args...; low=0, high=1)
96+
MinMax(args...) = LowHigh(args...; low=0, high=1)
9797

9898
"""
9999
Interquartile()
100100
101101
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)`.
103103
104104
Interquartile(col₁, col₂, ..., colₙ)
105105
Interquartile([col₁, col₂, ..., colₙ])
@@ -120,6 +120,6 @@ Interquartile(("a", "c", "e"))
120120
Interquartile(r"[ace]")
121121
```
122122
123-
See also [`Scale`](@ref).
123+
See also [`LowHigh`](@ref).
124124
"""
125-
Interquartile(args...) = Scale(args...; low=0.25, high=0.75)
125+
Interquartile(args...) = LowHigh(args...; low=0.25, high=0.75)

test/shows.jl

+14-14
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,17 @@
365365
└─ selector = all"""
366366
end
367367

368-
@testset "Scale" begin
369-
T = Scale()
368+
@testset "LowHigh" begin
369+
T = LowHigh()
370370

371371
# compact mode
372372
iostr = sprint(show, T)
373-
@test iostr == "Scale(all, 0.25, 0.75)"
373+
@test iostr == "LowHigh(all, 0.25, 0.75)"
374374

375375
# full mode
376376
iostr = sprint(show, MIME("text/plain"), T)
377377
@test iostr == """
378-
Scale transform
378+
LowHigh transform
379379
├─ selector = all
380380
├─ low = 0.25
381381
└─ high = 0.75"""
@@ -509,60 +509,60 @@
509509
@testset "SequentialTransform" begin
510510
t1 = Select(:x, :z)
511511
t2 = ZScore()
512-
t3 = Scale(low=0, high=1)
512+
t3 = LowHigh(low=0, high=1)
513513
pipeline = t1 t2 t3
514514

515515
# compact mode
516516
iostr = sprint(show, pipeline)
517-
@test iostr == "Select([:x, :z], nothing) → ZScore(all) → Scale(all, 0, 1)"
517+
@test iostr == "Select([:x, :z], nothing) → ZScore(all) → LowHigh(all, 0, 1)"
518518

519519
# full mode
520520
iostr = sprint(show, MIME("text/plain"), pipeline)
521521
@test iostr == """
522522
SequentialTransform
523523
├─ Select([:x, :z], nothing)
524524
├─ ZScore(all)
525-
└─ Scale(all, 0, 1)"""
525+
└─ LowHigh(all, 0, 1)"""
526526
end
527527

528528
@testset "ParallelTableTransform" begin
529-
t1 = Scale(low=0.3, high=0.6)
529+
t1 = LowHigh(low=0.3, high=0.6)
530530
t2 = EigenAnalysis(:VDV)
531531
t3 = Functional(exp)
532532
pipeline = t1 t2 t3
533533

534534
# compact mode
535535
iostr = sprint(show, pipeline)
536-
@test iostr == "Scale(all, 0.3, 0.6) ⊔ EigenAnalysis(:VDV, nothing, 1.0) ⊔ Functional(all, exp)"
536+
@test iostr == "LowHigh(all, 0.3, 0.6) ⊔ EigenAnalysis(:VDV, nothing, 1.0) ⊔ Functional(all, exp)"
537537

538538
# full mode
539539
iostr = sprint(show, MIME("text/plain"), pipeline)
540540
@test iostr == """
541541
ParallelTableTransform
542-
├─ Scale(all, 0.3, 0.6)
542+
├─ LowHigh(all, 0.3, 0.6)
543543
├─ EigenAnalysis(:VDV, nothing, 1.0)
544544
└─ Functional(all, exp)"""
545545

546546
# parallel and sequential
547547
f1 = ZScore()
548-
f2 = Scale()
548+
f2 = LowHigh()
549549
f3 = Functional(exp)
550550
f4 = Interquartile()
551551
pipeline = (f1 f2) (f3 f4)
552552

553553
# compact mode
554554
iostr = sprint(show, pipeline)
555-
@test iostr == "ZScore(all) → Scale(all, 0.25, 0.75) ⊔ Functional(all, exp) → Scale(all, 0.25, 0.75)"
555+
@test iostr == "ZScore(all) → LowHigh(all, 0.25, 0.75) ⊔ Functional(all, exp) → LowHigh(all, 0.25, 0.75)"
556556

557557
# full mode
558558
iostr = sprint(show, MIME("text/plain"), pipeline)
559559
@test iostr == """
560560
ParallelTableTransform
561561
├─ SequentialTransform
562562
│ ├─ ZScore(all)
563-
│ └─ Scale(all, 0.25, 0.75)
563+
│ └─ LowHigh(all, 0.25, 0.75)
564564
└─ SequentialTransform
565565
├─ Functional(all, exp)
566-
└─ Scale(all, 0.25, 0.75)"""
566+
└─ LowHigh(all, 0.25, 0.75)"""
567567
end
568568
end

test/transforms/parallel.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
z = y + rand(Normal(0, 5), 1500)
55
t = Table(; x, y, z)
66

7-
T = Scale(low=0.3, high=0.6) EigenAnalysis(:VDV)
7+
T = LowHigh(low=0.3, high=0.6) EigenAnalysis(:VDV)
88
n, c = apply(T, t)
99
tₒ = revert(T, n, c)
1010
@test Tables.matrix(t) Tables.matrix(tₒ)
@@ -16,7 +16,7 @@
1616

1717
# distributivity with respect to sequential transform
1818
T₁ = Center()
19-
T₂ = Scale(low=0.2, high=0.8)
19+
T₂ = LowHigh(low=0.2, high=0.8)
2020
T₃ = EigenAnalysis(:VD)
2121
P₁ = T₁ (T₂ T₃)
2222
P₂ = (T₁ T₂) (T₁ T₃)
@@ -26,7 +26,7 @@
2626

2727
# row table
2828
rt = Tables.rowtable(t)
29-
T = Scale(low=0.3, high=0.6) EigenAnalysis(:VDV)
29+
T = LowHigh(low=0.3, high=0.6) EigenAnalysis(:VDV)
3030
n, c = apply(T, rt)
3131
@test Tables.isrowtable(n)
3232
rtₒ = revert(T, n, c)

test/transforms/scale.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@testset "Scale" begin
2-
@test TT.parameters(Scale(:a)) == (low=0.25, high=0.75)
1+
@testset "LowHigh" begin
2+
@test TT.parameters(LowHigh(:a)) == (low=0.25, high=0.75)
33

44
# constant column
55
x = fill(3.0, 10)
@@ -15,7 +15,7 @@
1515
x = rand(rng, Normal(4, 3), 4000)
1616
y = rand(rng, Normal(7, 5), 4000)
1717
t = Table(; x, y)
18-
T = Scale(low=0, high=1)
18+
T = LowHigh(low=0, high=1)
1919
n, c = apply(T, t)
2020
@test all((1), n.x)
2121
@test all((0), n.x)
@@ -26,7 +26,7 @@
2626

2727
# row table
2828
rt = Tables.rowtable(t)
29-
T = Scale()
29+
T = LowHigh()
3030
n, c = apply(T, rt)
3131
@test Tables.isrowtable(n)
3232
rtₒ = revert(T, n, c)
@@ -35,7 +35,7 @@
3535
# columntype does not change
3636
for FT in (Float16, Float32)
3737
t = Table(; x=rand(FT, 10))
38-
for T in (MinMax(), Interquartile(), Scale(low=0, high=0.5))
38+
for T in (MinMax(), Interquartile(), LowHigh(low=0, high=0.5))
3939
n, c = apply(T, t)
4040
@test Tables.columntype(t, :x) == Tables.columntype(n, :x)
4141
tₒ = revert(T, n, c)
@@ -47,7 +47,7 @@
4747
z = x + y
4848
t = Table(; x, y, z)
4949

50-
T = Scale(1, 2, low=0, high=1)
50+
T = LowHigh(1, 2, low=0, high=1)
5151
n, c = apply(T, t)
5252
@test all((1), n.x)
5353
@test all((0), n.x)
@@ -56,7 +56,7 @@
5656
tₒ = revert(T, n, c)
5757
@test Tables.matrix(t) Tables.matrix(tₒ)
5858

59-
T = Scale([:x, :y], low=0, high=1)
59+
T = LowHigh([:x, :y], low=0, high=1)
6060
n, c = apply(T, t)
6161
@test all((1), n.x)
6262
@test all((0), n.x)
@@ -65,7 +65,7 @@
6565
tₒ = revert(T, n, c)
6666
@test Tables.matrix(t) Tables.matrix(tₒ)
6767

68-
T = Scale(("x", "y"), low=0, high=1)
68+
T = LowHigh(("x", "y"), low=0, high=1)
6969
n, c = apply(T, t)
7070
@test all((1), n.x)
7171
@test all((0), n.x)
@@ -74,7 +74,7 @@
7474
tₒ = revert(T, n, c)
7575
@test Tables.matrix(t) Tables.matrix(tₒ)
7676

77-
T = Scale(r"[xy]", low=0, high=1)
77+
T = LowHigh(r"[xy]", low=0, high=1)
7878
n, c = apply(T, t)
7979
@test all((1), n.x)
8080
@test all((0), n.x)

test/transforms/sequential.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
z = y + rand(Normal(0, 5), 1500)
55
t = Table(; x, y, z)
66

7-
T = Scale(low=0.2, high=0.8) EigenAnalysis(:VDV)
7+
T = LowHigh(low=0.2, high=0.8) EigenAnalysis(:VDV)
88
n, c = apply(T, t)
99
tₒ = revert(T, n, c)
1010
@test Tables.matrix(t) Tables.matrix(tₒ)
@@ -18,7 +18,7 @@
1818

1919
# row table
2020
rt = Tables.rowtable(t)
21-
T = Scale(low=0.2, high=0.8) EigenAnalysis(:VDV)
21+
T = LowHigh(low=0.2, high=0.8) EigenAnalysis(:VDV)
2222
n, c = apply(T, rt)
2323
@test Tables.isrowtable(n)
2424
rtₒ = revert(T, n, c)

0 commit comments

Comments
 (0)