pub struct ClusterSupportingObjects { /* private fields */ }
Implementations§
Source§impl ClusterSupportingObjects
impl ClusterSupportingObjects
Sourcepub fn count(&self) -> usize
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}
Sourcepub fn object_type(&self, id: usize) -> ObjectType
pub fn object_type(&self, id: usize) -> ObjectType
Identifies how an object was classified by the algorithm.
Sourcepub fn approximate_fuzzy_memberships(self, steps: usize, epsilon: f64) -> Self
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}
Sourcepub fn assign_outliers(self) -> Self
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}
Sourcepub fn make_clusters(&self, thd: f64) -> (Vec<Vec<usize>>, Vec<usize>)
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§
Auto Trait Implementations§
impl Freeze for ClusterSupportingObjects
impl RefUnwindSafe for ClusterSupportingObjects
impl Send for ClusterSupportingObjects
impl Sync for ClusterSupportingObjects
impl Unpin for ClusterSupportingObjects
impl UnwindSafe for ClusterSupportingObjects
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more