Skip to content

fix figure & cleanup #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 12, 2022
Merged

fix figure & cleanup #422

merged 8 commits into from
Jan 12, 2022

Conversation

st--
Copy link
Member

@st-- st-- commented Jan 11, 2022

@theogf apologies I had made a mistake with Plots... and then I also cleaned up the code a bit more

@st-- st-- requested a review from theogf January 11, 2022 15:41
@st--
Copy link
Member Author

st-- commented Jan 11, 2022

I've taken the opportunity to bump the LIBSVM dependency, deprecating #413

@codecov
Copy link

codecov bot commented Jan 11, 2022

Codecov Report

Merging #422 (acffc5e) into master (40cb59e) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #422   +/-   ##
=======================================
  Coverage   92.74%   92.74%           
=======================================
  Files          52       52           
  Lines        1199     1199           
=======================================
  Hits         1112     1112           
  Misses         87       87           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40cb59e...acffc5e. Read the comment docs.

Comment on lines 26 to 27
X1 = [cos.(angle1) sin.(angle1)] .+ 0.1randn(n1, 2)
X2 = [1 .- cos.(angle2) 1 .- sin.(angle2) .- 0.5] .+ 0.1randn(n2, 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.1randn(n1, 2) creates two arrays that can be avoided:

Suggested change
X1 = [cos.(angle1) sin.(angle1)] .+ 0.1randn(n1, 2)
X2 = [1 .- cos.(angle2) 1 .- sin.(angle2) .- 0.5] .+ 0.1randn(n2, 2)
X1 = [cos.(angle1) sin.(angle1)] .+ 0.1 .* randn.()
X2 = [1 .- cos.(angle2) 1 .- sin.(angle2) .- 0.5] .+ 0.1 .* randn.()

Alternatively, with one allocation:

Suggested change
X1 = [cos.(angle1) sin.(angle1)] .+ 0.1randn(n1, 2)
X2 = [1 .- cos.(angle2) 1 .- sin.(angle2) .- 0.5] .+ 0.1randn(n2, 2)
X1 = [cos.(angle1) sin.(angle1)] .+ 0.1 .* randn(n1, 2)
X2 = [1 .- cos.(angle2) 1 .- sin.(angle2) .- 0.5] .+ 0.1 .* randn(n2, 2)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the number of allocations makes no practical difference... but not having to pass the shape is neat! I didn't know randn.() works like that, I would have thought it only shifts everything by the same amount.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn! This is nice! I never new about x .+ randn.() is it working because of broadcast fusion?

@@ -49,7 +48,7 @@ model = svmtrain(kernelmatrix(k, x_train), y_train; kernel=LIBSVM.Kernel.Precomp
y_pred, _ = svmpredict(model, kernelmatrix(k, x_train, x_test));

# Visualize prediction on a grid:
plot(; lim=extrema(test_range), aspect_ratio=1)
plot(; xlim=extrema(test_range), ylim=extrema(test_range), aspect_ratio=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you want

Suggested change
plot(; xlim=extrema(test_range), ylim=extrema(test_range), aspect_ratio=1)
plot(; widen=false, aspect_ratio=1)

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that doesn't fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess you might have to specify the keyword argument when you actually plot data since otherwise subsequent calls might update the limits. I missed that there's nothing plotted in this call here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, widen isn't actually needed. Looks like updating Plots.jl seems to have fixed it though 😅

st-- and others added 4 commits January 11, 2022 17:07
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
@st--
Copy link
Member Author

st-- commented Jan 12, 2022

Can I have an approve to merge while even the nightly build is passing? 😂

@st-- st-- merged commit 93d33c2 into master Jan 12, 2022
@st-- st-- deleted the st/svm_example branch January 12, 2022 13:11
Crown421 added a commit that referenced this pull request Jan 28, 2022
commit f9bbd84
Author: st-- <st--@users.noreply.github.com>
Date:   Fri Jan 28 09:11:50 2022 +0100

    make nystrom work with AbstractVector (#427)

    * make nystrom work with AbstractVector

    * add test

    * Update test/approximations/nystrom.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * patch bump

    * Update test/approximations/nystrom.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * Apply suggestions from code review

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

    * Apply suggestions from code review

    * deprecate

    * Apply suggestions from code review

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * Apply suggestions from code review

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

    * Apply suggestions from code review

    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>

    * Update src/approximations/nystrom.jl

    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>

    * Update src/approximations/nystrom.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>

commit d1c68a9
Author: st-- <st--@users.noreply.github.com>
Date:   Thu Jan 13 22:33:43 2022 +0100

    fix Distances compat (#423)

    * CompatHelper: bump compat for Distances to 0.10 for package test, (keep existing compat)

    * try out Theo's fix

    * fix test compat

    * use ForwardDiff for chain rule test of SqMahalanobis

    * test on 1.4 instead of 1.3 - see if the chainrules test passes there

    * revert version branch

    * revert to 1.3

    * test_broken for older Julia versions

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>

commit 93d33c2
Author: st-- <st--@users.noreply.github.com>
Date:   Wed Jan 12 14:11:14 2022 +0100

    fix figure & cleanup (#422)

    * fix figure & cleanup

    * bump LIBSVM compat & Manifest

    * improve writing, replaces #321

commit 40cb59e
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Jan 12 09:39:01 2022 +0200

    CompatHelper: bump compat for Kronecker to 0.5 for package docs, (keep existing compat) (#367)

    * CompatHelper: bump compat for Kronecker to 0.5 for package docs, (keep existing compat)

    * ] up

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit 7204529
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Tue Jan 11 18:37:23 2022 +0200

    CompatHelper: bump compat for Kronecker to 0.5 for package test, (keep existing compat) (#366)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit 924925d
Author: st-- <st--@users.noreply.github.com>
Date:   Tue Jan 11 16:26:02 2022 +0100

    switch SVM example to half-moon dataset (#421)

commit 992b665
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Fri Dec 24 12:18:56 2021 +0200

    CompatHelper: bump compat for SpecialFunctions to 2 for package test, (keep existing compat) (#412)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit 04fa7f7
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu Dec 23 13:33:59 2021 +0200

    CompatHelper: bump compat for SpecialFunctions to 2, (keep existing compat) (#411)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit c0fc3e1
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu Dec 23 01:10:40 2021 +0200

    CompatHelper: add new compat entry for Compat at version 3 for package test, (keep existing compat) (#418)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>

commit 05fe340
Author: st-- <st--@users.noreply.github.com>
Date:   Tue Dec 21 00:49:37 2021 +0200

    use only() instead of first() (#403)

    * use only() instead of first() for 1-"vectors" that were for the benefit of Flux

    * fix one test that should not have worked as it was

    * add missing scalar Sinus constructor

commit 2d17212
Author: st-- <st--@users.noreply.github.com>
Date:   Sat Dec 18 23:43:30 2021 +0200

    Zygote AD failure workarounds & test cleanup (#414)

    Zygote AD failures:

    * revert #409 (test_utils workaround for broken Zygote - now working again)

    * disable broken Zygote AD test for ChainTransform

    Improved tests:

    * finer-grained testsets

    * add missing test cases to test_AD

    * replace test_FiniteDiff with test_AD(..., :FiniteDiff, ...)

    * remove code duplication

commit 3c49949
Author: Théo Galy-Fajou <theo.galyfajou@gmail.com>
Date:   Wed Nov 24 18:32:19 2021 +0100

    Fix typo in valid_inputs error (#408)

    * Fix typo in valid_inputs error

    * Update src/utils.jl

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

commit 9955044
Author: st-- <st--@users.noreply.github.com>
Date:   Wed Nov 24 18:55:18 2021 +0200

    Fix for Zygote 0.6.30 breaking our tests (#409)

    * restrict Zygote to <0.6.30

    * revert Zygote test restriction and add finer-grained testset

    * Update test/utils.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * revert testset

    * mark test_broken

    * Use `@test_throws` instead of `@test_broken`

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

commit 33d64d1
Author: Théo Galy-Fajou <theo.galyfajou@gmail.com>
Date:   Thu Nov 4 14:23:57 2021 +0100

    Add benchmarking CI (#399)

    * Add benchmark file

    * delete old benchmarks

    * Add github action

    * Add Project

    * Apply suggestions from code review

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * Missing end of line

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit 360ce10
Author: David Widmann <devmotion@users.noreply.github.com>
Date:   Tue Nov 2 11:09:58 2021 +0100

    Update docstring of `GibbsKernel` (#395)
st-- added a commit that referenced this pull request Mar 21, 2022
* initial version of training kernel parameters example from st/examples (#234)

* update script

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix out-of-domain initial value

* initial version of training kernel parameters example from st/examples (#234)

* update script

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix out-of-domain initial value

* Add ParameterHandling

* Extend example

* Failed attempts with default Flux opt

* Add Flux.destructure example

* Add some nothing

* Squashed commit of the following:

commit f9bbd84
Author: st-- <st--@users.noreply.github.com>
Date:   Fri Jan 28 09:11:50 2022 +0100

    make nystrom work with AbstractVector (#427)

    * make nystrom work with AbstractVector

    * add test

    * Update test/approximations/nystrom.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * patch bump

    * Update test/approximations/nystrom.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * Apply suggestions from code review

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

    * Apply suggestions from code review

    * deprecate

    * Apply suggestions from code review

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * Apply suggestions from code review

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

    * Apply suggestions from code review

    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>

    * Update src/approximations/nystrom.jl

    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>

    * Update src/approximations/nystrom.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>

commit d1c68a9
Author: st-- <st--@users.noreply.github.com>
Date:   Thu Jan 13 22:33:43 2022 +0100

    fix Distances compat (#423)

    * CompatHelper: bump compat for Distances to 0.10 for package test, (keep existing compat)

    * try out Theo's fix

    * fix test compat

    * use ForwardDiff for chain rule test of SqMahalanobis

    * test on 1.4 instead of 1.3 - see if the chainrules test passes there

    * revert version branch

    * revert to 1.3

    * test_broken for older Julia versions

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>

commit 93d33c2
Author: st-- <st--@users.noreply.github.com>
Date:   Wed Jan 12 14:11:14 2022 +0100

    fix figure & cleanup (#422)

    * fix figure & cleanup

    * bump LIBSVM compat & Manifest

    * improve writing, replaces #321

commit 40cb59e
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Jan 12 09:39:01 2022 +0200

    CompatHelper: bump compat for Kronecker to 0.5 for package docs, (keep existing compat) (#367)

    * CompatHelper: bump compat for Kronecker to 0.5 for package docs, (keep existing compat)

    * ] up

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit 7204529
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Tue Jan 11 18:37:23 2022 +0200

    CompatHelper: bump compat for Kronecker to 0.5 for package test, (keep existing compat) (#366)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit 924925d
Author: st-- <st--@users.noreply.github.com>
Date:   Tue Jan 11 16:26:02 2022 +0100

    switch SVM example to half-moon dataset (#421)

commit 992b665
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Fri Dec 24 12:18:56 2021 +0200

    CompatHelper: bump compat for SpecialFunctions to 2 for package test, (keep existing compat) (#412)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit 04fa7f7
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu Dec 23 13:33:59 2021 +0200

    CompatHelper: bump compat for SpecialFunctions to 2, (keep existing compat) (#411)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
    Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>
    Co-authored-by: st-- <st--@users.noreply.github.com>

commit c0fc3e1
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu Dec 23 01:10:40 2021 +0200

    CompatHelper: add new compat entry for Compat at version 3 for package test, (keep existing compat) (#418)

    Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>

commit 05fe340
Author: st-- <st--@users.noreply.github.com>
Date:   Tue Dec 21 00:49:37 2021 +0200

    use only() instead of first() (#403)

    * use only() instead of first() for 1-"vectors" that were for the benefit of Flux

    * fix one test that should not have worked as it was

    * add missing scalar Sinus constructor

commit 2d17212
Author: st-- <st--@users.noreply.github.com>
Date:   Sat Dec 18 23:43:30 2021 +0200

    Zygote AD failure workarounds & test cleanup (#414)

    Zygote AD failures:

    * revert #409 (test_utils workaround for broken Zygote - now working again)

    * disable broken Zygote AD test for ChainTransform

    Improved tests:

    * finer-grained testsets

    * add missing test cases to test_AD

    * replace test_FiniteDiff with test_AD(..., :FiniteDiff, ...)

    * remove code duplication

commit 3c49949
Author: Théo Galy-Fajou <theo.galyfajou@gmail.com>
Date:   Wed Nov 24 18:32:19 2021 +0100

    Fix typo in valid_inputs error (#408)

    * Fix typo in valid_inputs error

    * Update src/utils.jl

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

commit 9955044
Author: st-- <st--@users.noreply.github.com>
Date:   Wed Nov 24 18:55:18 2021 +0200

    Fix for Zygote 0.6.30 breaking our tests (#409)

    * restrict Zygote to <0.6.30

    * revert Zygote test restriction and add finer-grained testset

    * Update test/utils.jl

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * revert testset

    * mark test_broken

    * Use `@test_throws` instead of `@test_broken`

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

commit 33d64d1
Author: Théo Galy-Fajou <theo.galyfajou@gmail.com>
Date:   Thu Nov 4 14:23:57 2021 +0100

    Add benchmarking CI (#399)

    * Add benchmark file

    * delete old benchmarks

    * Add github action

    * Add Project

    * Apply suggestions from code review

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

    * Missing end of line

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit 360ce10
Author: David Widmann <devmotion@users.noreply.github.com>
Date:   Tue Nov 2 11:09:58 2021 +0100

    Update docstring of `GibbsKernel` (#395)

* change title

* Update manifest

* Formatter

* Some small updates

* Add BenchmarkTools

* Move Benchmarks to the correct manifest

* Formatter

* Fix missed comment

* Add ParameterHandling too

* Change gif embed

* Forgot #

* Formatter

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Compat and gif kwargs

* , for ;

* different commit msg

* Some more clarification

* Change display

* Final changes

* Apply suggestions from code review

Co-authored-by: st-- <st--@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: st-- <st--@users.noreply.github.com>

* Address comments

* Missed one

* Manifest issue

* Apply suggestions from formatter

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Local formatter

* Delete loss description.

Co-authored-by: st-- <st--@users.noreply.github.com>

* format

Co-authored-by: ST John <st--@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants