#[derive(Debug, Clone, Copy)]
pub struct Attribute {
pub id: u32,
pub value: f64,
}
pub type Item = Vec<Attribute>;
#[derive(Debug, Clone)]
pub struct Instance {
pub num_items: u32,
pub items: Vec<Item>,
pub labels: Vec<u32>,
pub weight: f64,
}
impl Attribute {
pub fn new(id: u32, value: f64) -> Self {
Self { id, value }
}
}
impl Instance {
pub fn with_capacity(cap: usize) -> Self {
Self {
num_items: 0,
items: Vec::with_capacity(cap),
labels: Vec::with_capacity(cap),
weight: 1.0,
}
}
pub fn push(&mut self, item: Item, label: u32) {
self.items.push(item);
self.labels.push(label);
self.num_items += 1;
}
pub fn set_weight(&mut self, weight: f64) {
self.weight = weight;
}
}