Skip to content

Commit b1945ed

Browse files
authored
Merge pull request #19 from JuliaAI/levels
Bump CategoricalArrays="1"
2 parents 7e268de + 779dcbd commit b1945ed

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18-
- '1.6'
18+
- 'lts'
1919
- '1'
2020
os:
2121
- ubuntu-latest
2222
arch:
2323
- x64
2424
steps:
2525
- uses: actions/checkout@v2
26-
- uses: julia-actions/setup-julia@v1
26+
- uses: julia-actions/setup-julia@v2
2727
with:
2828
version: ${{ matrix.version }}
2929
arch: ${{ matrix.arch }}
30-
- uses: actions/cache@v1
30+
- uses: julia-actions/cache@v2
3131
env:
3232
cache-name: cache-artifacts
3333
with:

Project.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
name = "MLJLIBSVMInterface"
22
uuid = "61c7150f-6c77-4bb1-949c-13197eac2a52"
33
authors = ["Anthony D. Blaom <[email protected]>"]
4-
version = "0.2.1"
4+
version = "0.2.2"
55

66
[deps]
77
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
8+
CategoricalDistributions = "af321ab8-2d2e-40a6-b165-3d674595d28e"
89
LIBSVM = "b1bec4e5-fd48-53fe-b0cb-9723c09d164b"
910
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
1011
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1112

1213
[compat]
13-
CategoricalArrays = "0.10"
14+
CategoricalArrays = "1"
15+
CategoricalDistributions = "0.2.1"
1416
LIBSVM = "0.8"
1517
MLJModelInterface = "1.4"
16-
julia = "1.6"
18+
Statistics = "1"
19+
julia = "1.10"
1720

1821
[extras]
1922
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2023
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
2124
MLJTestInterface = "72560011-54dd-4dc2-94f3-c5de45b75ecd"
2225
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
26+
StatisticalMeasures = "a19d573c-0a75-4610-95b3-7071388c7541"
2327
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2428

2529
[targets]
26-
test = ["LinearAlgebra", "MLJBase", "MLJTestInterface", "StableRNGs", "Test"]
30+
test = ["LinearAlgebra", "MLJBase", "MLJTestInterface", "StableRNGs", "StatisticalMeasures", "Test"]

src/MLJLIBSVMInterface.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export ProbabilisticNuSVC
1010
import MLJModelInterface
1111
import MLJModelInterface: Table, Continuous, Count, Finite, OrderedFactor,
1212
Multiclass
13-
import CategoricalArrays
13+
import CategoricalArrays, CategoricalDistributions
1414
import LIBSVM
1515
using Statistics
1616

@@ -384,13 +384,12 @@ function encode(weights::Dict, y)
384384
kys = CategoricalArrays.levels(y)
385385
Set(keys(weights)) == Set(kys) || throw(err_bad_weights(kys))
386386
_weights = fix_keys(weights, y)
387-
levels_seen = unique(y) # not `CategoricalValue`s !
388-
cvs = [categorical_value(x, y) for x in levels_seen]
389-
return Dict(MMI.int(cv) => _weights[cv] for cv in cvs)
387+
levels_seen = unique(y)
388+
return Dict(CategoricalDistributions.int(cv) => _weights[cv] for cv in levels_seen)
390389
end
391390

392391
function get_encoding(decoder)
393-
refs = MMI.int.(decoder.classes)
392+
refs = CategoricalDistributions.int.(CategoricalArrays.levels(decoder))
394393
return Dict(i => decoder(i) for i in refs)
395394
end
396395

@@ -430,8 +429,8 @@ function MMI.fit(
430429
)
431430

432431
Xmatrix = MMI.matrix(X)' # notice the transpose
433-
y_plain = MMI.int(y)
434-
decode = MMI.decoder(y[1]) # for predict method
432+
y_plain = CategoricalDistributions.int(y)
433+
decode = CategoricalDistributions.decoder(y[1]) # for predict method
435434

436435
_weights = if weights == nothing
437436
nothing
@@ -464,8 +463,8 @@ function MMI.fit(
464463
)
465464

466465
Xmatrix = MMI.matrix(X)' # notice the transpose
467-
y_plain = MMI.int(y)
468-
decode = MMI.decoder(y[1]) # for predict method
466+
y_plain = CategoricalDistributions.int(y)
467+
decode = CategoricalDistributions.decoder(y[1]) # for predict method
469468

470469
_weights = if weights == nothing
471470
nothing

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using MLJLIBSVMInterface
66
import StableRNGs
77
import LIBSVM
88
import MLJTestInterface
9+
using StatisticalMeasures
910

1011
@testset "`fix_keys` and `encode` for weight dicts" begin
1112
v = categorical(['a', 'b', 'b', 'c'])
@@ -51,7 +52,7 @@ end
5152
data...;
5253
mod=@__MODULE__,
5354
verbosity=0, # bump to debug
54-
throw=false, # set to true to debug
55+
throw=true, # set to true to debug
5556
)
5657
@test isempty(failures)
5758
end

0 commit comments

Comments
 (0)