LossFunctions.jl is a Julia package that provides efficient andwell-tested implementations for a diverse set of loss functionsthat are commonly used in Machine Learning.
Distance-based (Regression) | Margin-based (Classification) |
---|---|
Please consult the documentationfor other losses.
Typically, the loss functions we work with in Machine Learningfall into the category of supervised losses. These aremultivariate functions of two variables, the true target y
,which represents the "ground truth" (i.e. correct answer), andthe predicted output ŷ
, which is what our model thinks thetruth is. A supervised loss function takes these two variables asinput and returns a value that quantifies how "bad" ourprediction is in comparison to the truth. In other words: thelower the loss, the better the prediction.
This package provides a considerable amount of carefullyimplemented loss functions, as well as an API to query theirproperties (e.g. convexity). Furthermore, we expose methods tocompute their values, derivatives, and second derivatives forsingle observations as well as arbitrarily sized arrays ofobservations. In the case of arrays a user additionally has theability to define if and how element-wise results are averaged orsummed over.
Check out the latest documentation
Additionally, you can make use of Julia's native docsystem.The following example shows how to get additional informationon HingeLoss
within Julia's REPL:
?HingeLoss
search: HingeLoss L2HingeLoss L1HingeLoss SmoothedL1HingeLoss
L1HingeLoss <: MarginLoss
The hinge loss linearly penalizes every predicition where the
resulting agreement a = y⋅ŷ < 1 . It is Lipschitz continuous
and convex, but not strictly convex.
L(a) = \max \{ 0, 1 - a \}
--------------------------------------------------------------------
Lossfunction Derivative
┌────────────┬────────────┐ ┌────────────┬────────────┐
3 │'\. │ 0 │ ┌------│
│ ''_ │ │ | │
│ \. │ │ | │
│ '. │ │ | │
L │ ''_ │ L' │ | │
│ \. │ │ | │
│ '. │ │ | │
0 │ ''_______│ -1 │------------------┘ │
└────────────┴────────────┘ └────────────┴────────────┘
-2 2 -2 2
y ⋅ ŷ y ⋅ ŷ
Get the latest stable release with Julia's package manager:
] add LossFunctions
This code is free to use under the terms of the MIT license.
LowRankModels.jl是一个用于建模和拟合广义低阶模型(GLRMs)的Julia工具包。 LowRankModels.jl is a julia package for modeling and fitting generalized low rank models (GLRMs). GLRMs用低阶矩阵对一个数据数组进行建模,并在数据分析中包括了许多著名的模型,如主成分分析(PCA)