Struct ClusterSupportingObjects

Source
pub struct ClusterSupportingObjects { /* private fields */ }

Implementations§

Source§

impl ClusterSupportingObjects

Source

pub fn count(&self) -> usize

Returns the number of cluster supporting objects.

Examples found in repository?
examples/sample.rs (line 67)
55fn main() -> io::Result<()> {
56    let filename = env::args().nth(1);
57    if filename.is_none() {
58        eprintln!("No input file");
59        exit(1);
60    }
61    let data = read_data(io::BufReader::new(File::open(filename.unwrap())?))?;
62    let flame = DistanceGraph::build(&data, distance::euclidean);
63
64    print!("Detecting Cluster Supporting Objects ...");
65    io::stdout().flush()?;
66    let supports = flame.find_supporting_objects(10, -2.0);
67    println!("done, found {}", supports.count());
68
69    print!("Propagating fuzzy memberships ... ");
70    io::stdout().flush()?;
71    let fuzzyships = supports
72        .approximate_fuzzy_memberships(500, 1e-6)
73        .assign_outliers();
74    println!("done");
75
76    print!("Defining clusters from fuzzy memberships ... ");
77    io::stdout().flush()?;
78    let (clusters, outliers) = fuzzyships.make_clusters(-1.0);
79    println!("done");
80
81    for (i, cluster) in clusters.iter().enumerate() {
82        print!("\nCluster {:3}, with {:6} members:\n", i + 1, cluster.len());
83        print_cluster(cluster);
84    }
85    print!("\nCluster outliers, with {:6} members:\n", outliers.len());
86    print_cluster(&outliers);
87
88    Ok(())
89}
Source

pub fn object_type(&self, id: usize) -> ObjectType

Identifies how an object was classified by the algorithm.

Source

pub fn approximate_fuzzy_memberships(self, steps: usize, epsilon: f64) -> Self

Local Approximation of fuzzy memberships. Stopped after the maximum steps of iterations; Or stopped when the overall membership difference between two iterations become less than epsilon.

Examples found in repository?
examples/sample.rs (line 72)
55fn main() -> io::Result<()> {
56    let filename = env::args().nth(1);
57    if filename.is_none() {
58        eprintln!("No input file");
59        exit(1);
60    }
61    let data = read_data(io::BufReader::new(File::open(filename.unwrap())?))?;
62    let flame = DistanceGraph::build(&data, distance::euclidean);
63
64    print!("Detecting Cluster Supporting Objects ...");
65    io::stdout().flush()?;
66    let supports = flame.find_supporting_objects(10, -2.0);
67    println!("done, found {}", supports.count());
68
69    print!("Propagating fuzzy memberships ... ");
70    io::stdout().flush()?;
71    let fuzzyships = supports
72        .approximate_fuzzy_memberships(500, 1e-6)
73        .assign_outliers();
74    println!("done");
75
76    print!("Defining clusters from fuzzy memberships ... ");
77    io::stdout().flush()?;
78    let (clusters, outliers) = fuzzyships.make_clusters(-1.0);
79    println!("done");
80
81    for (i, cluster) in clusters.iter().enumerate() {
82        print!("\nCluster {:3}, with {:6} members:\n", i + 1, cluster.len());
83        print_cluster(cluster);
84    }
85    print!("\nCluster outliers, with {:6} members:\n", outliers.len());
86    print_cluster(&outliers);
87
88    Ok(())
89}
Source

pub fn assign_outliers(self) -> Self

Attempt to assign outliers to the nearest cluster.

Examples found in repository?
examples/sample.rs (line 73)
55fn main() -> io::Result<()> {
56    let filename = env::args().nth(1);
57    if filename.is_none() {
58        eprintln!("No input file");
59        exit(1);
60    }
61    let data = read_data(io::BufReader::new(File::open(filename.unwrap())?))?;
62    let flame = DistanceGraph::build(&data, distance::euclidean);
63
64    print!("Detecting Cluster Supporting Objects ...");
65    io::stdout().flush()?;
66    let supports = flame.find_supporting_objects(10, -2.0);
67    println!("done, found {}", supports.count());
68
69    print!("Propagating fuzzy memberships ... ");
70    io::stdout().flush()?;
71    let fuzzyships = supports
72        .approximate_fuzzy_memberships(500, 1e-6)
73        .assign_outliers();
74    println!("done");
75
76    print!("Defining clusters from fuzzy memberships ... ");
77    io::stdout().flush()?;
78    let (clusters, outliers) = fuzzyships.make_clusters(-1.0);
79    println!("done");
80
81    for (i, cluster) in clusters.iter().enumerate() {
82        print!("\nCluster {:3}, with {:6} members:\n", i + 1, cluster.len());
83        print_cluster(cluster);
84    }
85    print!("\nCluster outliers, with {:6} members:\n", outliers.len());
86    print_cluster(&outliers);
87
88    Ok(())
89}
Source

pub fn make_clusters(&self, thd: f64) -> (Vec<Vec<usize>>, Vec<usize>)

Construct clusters. If 0<thd<1: each object is assigned to all clusters in which it has membership higher than thd; if it can not be assigned to any clusters, it is then assigned to the outlier group. Else: each object is assigned to the group (clusters/outlier group) in which it has the highest membership.

Examples found in repository?
examples/sample.rs (line 78)
55fn main() -> io::Result<()> {
56    let filename = env::args().nth(1);
57    if filename.is_none() {
58        eprintln!("No input file");
59        exit(1);
60    }
61    let data = read_data(io::BufReader::new(File::open(filename.unwrap())?))?;
62    let flame = DistanceGraph::build(&data, distance::euclidean);
63
64    print!("Detecting Cluster Supporting Objects ...");
65    io::stdout().flush()?;
66    let supports = flame.find_supporting_objects(10, -2.0);
67    println!("done, found {}", supports.count());
68
69    print!("Propagating fuzzy memberships ... ");
70    io::stdout().flush()?;
71    let fuzzyships = supports
72        .approximate_fuzzy_memberships(500, 1e-6)
73        .assign_outliers();
74    println!("done");
75
76    print!("Defining clusters from fuzzy memberships ... ");
77    io::stdout().flush()?;
78    let (clusters, outliers) = fuzzyships.make_clusters(-1.0);
79    println!("done");
80
81    for (i, cluster) in clusters.iter().enumerate() {
82        print!("\nCluster {:3}, with {:6} members:\n", i + 1, cluster.len());
83        print_cluster(cluster);
84    }
85    print!("\nCluster outliers, with {:6} members:\n", outliers.len());
86    print_cluster(&outliers);
87
88    Ok(())
89}

Trait Implementations§

Source§

impl Debug for ClusterSupportingObjects

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.