JuliaML / LossFunctions.jl

Julia package of loss functions for machine learning.
https://juliaml.github.io/LossFunctions.jl/stable
Other
147 stars 33 forks source link

Update plot recipe #129

Closed juliohm closed 4 years ago

juliohm commented 4 years ago

This PR addresses item (3) of issue #126. It gets rid of the internal Deriv and Deriv2 types previously used to define plot recipes. The new plot recipe is simpler and we can plot different traits of the loss by passing a keyword argument:

using LossFunctions
using Plots

l = L2DistLoss()

plot(l) # default to value
plot(l, fun=deriv) # equivalent to old Deriv
plot(l, fun=deriv2) # equivalent to old Deriv2

As a side note, the plot recipe is not covered by the current test suite. In my own packages I make use of VisualRegressionTests.jl for testing plot recipes. Would you be ok with adding it here as a test dependency as well?

codecov-io commented 4 years ago

Codecov Report

Merging #129 into master will increase coverage by 1.68%. The diff coverage is 77.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #129      +/-   ##
==========================================
+ Coverage   89.00%   90.68%   +1.68%     
==========================================
  Files          12       12              
  Lines         700      687      -13     
==========================================
  Hits          623      623              
+ Misses         77       64      -13     
Impacted Files Coverage Δ
src/LossFunctions.jl 100.00% <ø> (ø)
src/supervised/io.jl 38.70% <0.00%> (+10.13%) :arrow_up:
src/devutils.jl 100.00% <100.00%> (ø)
src/supervised/sparse.jl 100.00% <100.00%> (ø)
src/supervised/supervised.jl 91.12% <100.00%> (+1.06%) :arrow_up:

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 71041fb...4bd9d95. Read the comment docs.