Request for improved/updated beginner examples
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.7k
- Forks
- 334
- Avg merge
- 39m
- Merged PRs (30d)
- 1
Description
I'm looking to use linfa for k-means clustering, and the current k-means example is pretty incomprehensible to a newbie. It may be that this makes perfect sense to someone steeped in this API or even in ndarray, but to me, the issues are:
- The current version of
rand(0.9.0 as of Feb 2025) appears to be incompatible with the version used in the example - Generating random data from a PRNG doesn't help when my goal is to load data from somewhere else. How can I create a mutable data structure that I can push new vectors onto?
DatasetBaseindicates that it contains records and maybe targets, weights, and feature names. I have no clue what the target/weights are when I'm trying to create input.- Not having expected centroids, I'd like to lean on the API to either generate something random, something evenly distributed, or a use some quick heuristic otherwise.
Ultimately, my ideal is to do something like:
let mut records = Dataset::with_capacity(100_000); // expected number of input rows
for row in load_my_data("file.tsv") {
// where 'row' is, say, a [f64; 5] or a Vec<f32>?
records.push(row);
}
let initial_state = kmeans::generate_random_centroids(10 /* # clusters */, &records);
let clusters = kmeans::params_with(...).fit(&records);
for (id, cluster) in clusters.iter().enumerate() {
// presumably cluster is [f64; 5] or &[f32]
println!("Cluster {id} located @ {cluster:?}");
}
I realize this may diverge drastically from what currently exists, but I'd like to determine how to bridge this gap. Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with algorithms/linfa-clustering/examples/kmeans.rs and review the linked DatasetBase documentation. Run the existing example, then define a beginner-oriented example that explains loading rows, the meaning of targets and weights, centroid initialization, and the resulting clusters; done means the example is understandable without prior linfa or ndarray knowledge.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation, machine-learning
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100