Skip to main content

LinearClassifier

Struct LinearClassifier 

Source
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

Source

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.

Source

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.

Source

pub fn pair_count(&self) -> usize

The number of pairs of features with a weight.

§Returns

The number of pairs.

Trait Implementations§

Source§

impl Classifier for LinearClassifier

Source§

fn id(&self, feature: &str) -> Option<u32>

The number of a feature. Read more
Source§

fn score(&self, features: &[u32]) -> f64

The score of a decision. Read more
Source§

impl Clone for LinearClassifier

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LinearClassifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LinearClassifier

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LinearClassifier

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.