Visualisation of the Kmean generated cluster
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- rust
- Domain
- data-visualization
Research direction
Review the Rust example in Cargo.toml and main.rs, including the clustered_points.csv input and the Vega-Lite chart construction. Run the example with the provided clustered data and determine the expected visualization; the work is done when the generated cluster points are displayed correctly.
Written by the indexing model from the issue text.
Description
Hello,
This is the code for the visulalisation of the workshop using rust and vega_lite_3.
Cargo.toml
[dependencies]
vega_lite_3 = {version = "0.1", features = ["show_vega"]}
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.39"
derive_builder = "0.9.0"
showata = "0.1.0"
failure = "0.1.5"
csv = "1.1.1"
main.rs
use csv;
use failure;
use serde::{Deserialize, Serialize};
use showata::Showable;
use std::path::Path;
use vega_lite_3::*;
#[derive(Serialize, Deserialize, Debug)]
pub struct Item {
pub x: f64,
pub y: f64,
pub idx: usize,
}
macro_rules! build {
($s:expr ) => {
$s.build().map_err(|s| failure::format_err!("{}", s))?
};
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read in the data using the csv crate
// The data are organised this way:
//
// Point_ID ,Point_x,Point_y, Cluster_idx
// 0, 9.887634 , 10.700742, 3
// 1, 10.895053 , 9.602507, 3
// ...
// 1475, 1.959400, 13.254207, 1
let mut rdr = csv::Reader::from_path(Path::new("clustered_points.csv"))?;
let values = rdr
.deserialize()
.into_iter()
.collect::<Result<Vec<Item>, csv::Error>>()?;
// Create the plot
let chart = build!(VegaliteBuilder::default()
.title("Dataset Points")
.width(800.0)
.height(800.0)
.description("Plot of the clustered dataset generated in by ndarray workshop.")
.data(&values)
.mark(Mark::Point)
.encoding(build!(EncodingBuilder::default()
.x(build!(XClassBuilder::default()
.field("x")
.def_type(StandardType::Quantitative)))
.y(build!(YClassBuilder::default()
.field("y")
.def_type(StandardType::Quantitative)))
.color(ValueDefWithConditionMarkPropFieldDefStringNull {
aggregate: None,
bin: None,
condition: None,
field: Some(Field::String("idx".to_string())),
legend: None,
scale: None,
sort: None,
time_unit: None,
title: None,
value: None,
value_def_with_condition_mark_prop_field_def_string_null_type: None
}))));
chart.show()?;
Ok(())
}
- Dominant language
- Jupyter Notebook
- Stars
- 116
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
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.
More from LukeMathWalker/ndarray-koans
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
LukeMathWalker/ndarray-koans#7 · 1 comment ·
All issues in LukeMathWalker/ndarray-koans
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google/libultrahdr#485 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
gradio-app/gradio#13887 ·
-
internal
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
hemilabs/ui-monorepo#2344 ·