From 414ac01fa3e06413620f89288e2116de2eb70a81 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 28 Jan 2021 12:08:21 +1300 Subject: [PATCH 1/5] bump compatibility MLJModelInterface = "0.3.6,0.4"; adapt tests --- .github/workflows/CompatHelper.yml | 16 ++++++++++ Project.toml | 4 +-- README.md | 5 ---- test/models/clustering.jl | 48 ++++++++++++++---------------- test/runtests.jl | 1 + 5 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/CompatHelper.yml diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..2876f03 --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,16 @@ +name: CompatHelper +on: + schedule: + - cron: '00 00 * * *' + workflow_dispatch: +jobs: + CompatHelper: + runs-on: ubuntu-latest + steps: + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} # optional + run: julia -e 'using CompatHelper; CompatHelper.main()' \ No newline at end of file diff --git a/Project.toml b/Project.toml index 5c789d7..9697db7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJScikitLearnInterface" uuid = "5ae90465-5518-4432-b9d2-8a1def2f0cab" authors = ["Thibaut Lienart, Anthony Blaom"] -version = "0.1.7" +version = "0.1.8" [deps] MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" @@ -9,7 +9,7 @@ PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" ScikitLearn = "3646fa90-6ef7-5e7e-9f22-8aca16db6324" [compat] -MLJModelInterface = "0.3.6" +MLJModelInterface = "0.3.6,0.4" PyCall = "1" ScikitLearn = "0.5,0.6" julia = "1" diff --git a/README.md b/README.md index 7cc62c6..c7f7808 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,4 @@ Repository implementing MLJ interface for **Note**: for errors with MKL on Mac, please refer to [ScikitLearn.jl](https://github.com/cstjean/ScikitLearn.jl) as it's a known issue. -## Todo - -**June 2020** - -* Maybe more integration tests diff --git a/test/models/clustering.jl b/test/models/clustering.jl index 21584f0..4450575 100644 --- a/test/models/clustering.jl +++ b/test/models/clustering.jl @@ -29,7 +29,7 @@ models = ( if m in (AffinityPropagation, MeanShift) p = MB.predict(m, f, X) - @test p isa MB.CategoricalArray + @test p isa MB.CategoricalArray end @test keys(fp) == getproperty(fparams, Symbol(mod)) @@ -46,12 +46,11 @@ end @testset "Scitypes" begin for mod in models m = mod() - infos = MB.info_dict(m) - @test infos[:input_scitype] == MB.Table(MB.Continuous) + @test input_scitype(mod) == MB.Table(MB.Continuous) m == AffinityPropagation && - @test infos[:target_scitype] == AbstractVector{MB.Multiclass} - m == MeanShift && - @test infos[:output_scitype] == MB.Table(MB.Continuous) + @test target_scitype(mod) == AbstractVector{MB.Multiclass} + m == MeanShift && + @test output_scitype(mod) == MB.Table(MB.Continuous) end end @@ -69,10 +68,10 @@ models = ( fp = MB.fitted_params(m, f) @test size(fp.cluster_centers) == (4, 3) p = MB.predict(m, f, X) - @test p isa MB.CategoricalArray + @test p isa MB.CategoricalArray Xt = MB.transform(m, f, X) @test Xt isa MB.Tables.MatrixTable - + @test keys(fp) == getproperty(fparams, Symbol(mod)) end end @@ -87,10 +86,9 @@ end @testset "Scitypes" begin for mod in models m = mod() - infos = MB.info_dict(m) - @test infos[:input_scitype] == MB.Table(MB.Continuous) - @test infos[:target_scitype] == AbstractVector{MB.Multiclass} - @test infos[:output_scitype] == MB.Table(MB.Continuous) + @test input_scitype(mod) == MB.Table(MB.Continuous) + @test target_scitype(mod) == AbstractVector{MB.Multiclass} + @test output_scitype(mod) == MB.Table(MB.Continuous) end end @@ -107,19 +105,19 @@ models = ( f, = MB.fit(m, 1, X) fp = MB.fitted_params(m, f) @test fp.labels isa MB.CategoricalArray - + Xt = MB.transform(m, f, X) if mod == FeatureAgglomeration - @test fp.distances === nothing - Xit = MB.inverse_transform(m, f, Xt) + @test fp.distances === nothing + Xit = MB.inverse_transform(m, f, Xt) # NOTE: they're not equal (not sure why) @test Xit isa MB.Tables.MatrixTable - else + else p = MB.predict(m, f, X) - @test p isa MB.CategoricalArray + @test p isa MB.CategoricalArray @test Xt isa MB.Tables.MatrixTable - end - + end + @test keys(fp) == getproperty(fparams, Symbol(mod)) end end @@ -133,11 +131,10 @@ end @testset "Scitypes" begin for mod in models - infos = MB.info_dict(mod) - @test infos[:input_scitype] == MB.Table(MB.Continuous) + @test input_scitype(mod) == MB.Table(MB.Continuous) mod == Birch && - @test infos[:target_scitype] == AbstractVector{MB.Multiclass} - @test infos[:output_scitype] == MB.Table(MB.Continuous) + @test target_scitype(mod) == AbstractVector{MB.Multiclass} + @test output_scitype(mod) == MB.Table(MB.Continuous) end end @@ -152,7 +149,7 @@ model = ( m=mod() f, = MB.fit(m, 1, X) fp = MB.fitted_params(m, f) - @test fp.labels isa MB.CategoricalArray + @test fp.labels isa MB.CategoricalArray @test keys(fp) == getproperty(fparams, Symbol(mod)) end end @@ -167,7 +164,6 @@ end @testset "Scitypes" begin for mod in models m = mod() - infos = MB.info_dict(m) - @test infos[:input_scitype] == MB.Table(MB.Continuous) + @test input_scitype(mod) == MB.Table(MB.Continuous) end end diff --git a/test/runtests.jl b/test/runtests.jl index f2a8214..5b14e8e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,7 @@ using MLJScikitLearnInterface using Test import MLJBase import ScikitLearn +import MLJBase: target_scitype, input_scitype, output_scitype const MB = MLJBase From e2aaf9dfa5192c25544469ffbd19176da8071607 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 28 Jan 2021 12:36:35 +1300 Subject: [PATCH 2/5] use github action for ci --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..978228b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI +on: + pull_request: + branches: + - master + push: + branches: + - master + tags: '*' +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.0' + - '1' + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info From e189fe46d97261bc9820bd179293ad989a4985ee Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 28 Jan 2021 12:39:34 +1300 Subject: [PATCH 3/5] rm .travis --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 51d2253..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -### Documentation: http://docs.travis-ci.com/user/languages/julia/ -language: julia -os: - - linux -env: - global: - - PYTHON=Conda -julia: - - 1.0 - - 1.5 - - nightly -matrix: - allow_failures: - - julia: nightly -notifications: - email: false - -after_success: - - julia -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())' From 4715591811e3dc358f87a9919f928fe66124f55f Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 28 Jan 2021 12:52:12 +1300 Subject: [PATCH 4/5] add PYTHON=Conda to ci --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 978228b..d045e1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,6 @@ name: CI +env: + PYTHON=Conda on: pull_request: branches: From 17dde1db3089153d9e2e9d4e39ead7676ea0db51 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 28 Jan 2021 12:53:59 +1300 Subject: [PATCH 5/5] fix syntax in yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d045e1a..49e0a18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI env: - PYTHON=Conda + PYTHON: Conda on: pull_request: branches: