JuliaML / MLPlots.jl

Plotting recipes for statistics and machine learning using Plots.jl
Other
24 stars 5 forks source link

Add plot for MarginBasedLoss and DistanceBasedLoss #4

Closed Evizero closed 8 years ago

Evizero commented 8 years ago
using LearnBase
using LearnBase.LossFunctions
using MLPlots
pyplot()

You can treat a loss like a function.

plt = plot(L2DistLoss(), -2, 2, title = "Distance Based Loss Functions")
plot!(plt, L1DistLoss(), -3, 3)
plot!(plt, EpsilonInsLoss(1), -3, 3)

example

It is also possible to plot multiple Losses at once

plot([ZeroOneLoss(), LogitMarginLoss(), HingeLoss(), L2HingeLoss(), ModifiedHuberLoss()],
     title = "Loss Functions for Classification")

index

Evizero commented 8 years ago

By the way I am not quite sure how to make tests for this package.

tbreloff commented 8 years ago

Looks cool.

As for tests, we should eventually adopt something like what I have in Plots. I generate a PNG in a temporary location and compare it to a reference image. A mismatch will throw an error in travis, but interactively will bring up a GUI window to compare the difference and optionally save the new image as the reference image.

Don't worry about all that for now.