Struct fluent_data::algorithm::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
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more