Algo

Struct Algo 

Source
pub struct Algo<Point: PartialEq + 'static> { /* private fields */ }
Expand description

Fits incoming points to a set of balls model.

The algorithm can fit any kind of points in a space that:

  • defines the square of the distance between two points,
  • defines the weighted center of two points.
use fluent_data::algorithm::Algo;
use fluent_data::model::Model;
use fluent_data::space;

let dataset = vec![
       vec![5., -1.],
       vec![1., 1.],
       vec![11., -9.],
   ];
let algo = Algo::new(space::euclid_dist, space::real_combine);
let mut model = Model::new(space::euclid_dist);
for i in 0..3 {
   algo.fit(&mut model, dataset[i].clone());
}
let mut balls = model.iter_balls();
let first = balls.next().unwrap();
assert_eq!(&vec![6., -4.], first.center());
assert_eq!(f64::sqrt(110.), first.radius());
assert!(first.weight() < 2.001 && first.weight() > 1.999);

Implementations§

Source§

impl<Point: PartialEq + 'static> Algo<Point>

Source

pub fn new<Dist, Combine>(dist: Dist, combine: Combine) -> Self
where Dist: Fn(&Point, &Point) -> f64 + 'static, Combine: Fn(&Point, f64, &Point, f64) -> Point + 'static,

Creates a new algorithm for the given distance and combination functions.

Source

pub fn fit<'a>(&'a self, model: &'a mut Model<Point>, point: Point)

Fits the incoming points to the given mixture model.

Auto Trait Implementations§

§

impl<Point> Freeze for Algo<Point>

§

impl<Point> !RefUnwindSafe for Algo<Point>

§

impl<Point> !Send for Algo<Point>

§

impl<Point> !Sync for Algo<Point>

§

impl<Point> Unpin for Algo<Point>
where Point: Unpin,

§

impl<Point> !UnwindSafe for Algo<Point>

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,