pub struct LinearClassifier { /* private fields */ }Expand description
A linear classifier over features and pairs of features, with its weights in memory.
The score of a decision is the bias, plus the weight of each of its features, plus the weight of each pair of them. This is what the polynomial kernel of degree 2 of CaboCha and of J.DepP comes to once it is expanded.
It looks up every pair of the features of a decision in a hash table,
which is enough to parse with weights made by hand. A trained model is
a ParserModel, and in a model file a
ParserPart.
Implementations§
Source§impl LinearClassifier
impl LinearClassifier
Sourcepub fn new(
bias: f64,
features: HashMap<String, f64>,
pairs: HashMap<(String, String), f64>,
) -> Result<Self>
pub fn new( bias: f64, features: HashMap<String, f64>, pairs: HashMap<(String, String), f64>, ) -> Result<Self>
Makes a classifier from its weights.
§Arguments
bias- The bias.features- The weight of each feature.pairs- The weight of each pair of features, in either order. A feature named here only has the weight 0 on its own.
§Returns
The classifier, or Error::Parser for a weight that is not
finite, a pair of a feature with itself, or a pair given in both
orders.
Sourcepub fn feature_count(&self) -> usize
pub fn feature_count(&self) -> usize
The number of features the classifier knows.
§Returns
The number of features with a weight or in a pair.