Nasty.AST.Classification (Nasty v0.3.0)
View SourceClassification result representing the predicted class for a document.
Used by text classification systems to represent predictions with confidence scores and probability distributions.
Summary
Types
Functions
@spec new(atom(), float(), Nasty.AST.Node.language(), keyword()) :: t()
Creates a new classification result.
Examples
iex> classification = Nasty.AST.Classification.new(:spam, 0.95, :en)
iex> classification.class
:spam
iex> classification.confidence
0.95
Sorts classifications by confidence (highest first).
Examples
iex> classifications = [
...> Nasty.AST.Classification.new(:low, 0.3, :en),
...> Nasty.AST.Classification.new(:high, 0.9, :en),
...> Nasty.AST.Classification.new(:mid, 0.6, :en)
...> ]
iex> sorted = Nasty.AST.Classification.sort_by_confidence(classifications)
iex> Enum.map(sorted, & &1.class)
[:high, :mid, :low]