From f4c86d83629b282f39cc3750d42c8afe77d24fe9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 12 Jan 2025 22:33:48 +0200 Subject: hw(AI/6): Progress --- Year 4/Artificial Intelligence/hw06/src/tree.rs | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Year 4/Artificial Intelligence/hw06/src/tree.rs (limited to 'Year 4/Artificial Intelligence/hw06/src/tree.rs') diff --git a/Year 4/Artificial Intelligence/hw06/src/tree.rs b/Year 4/Artificial Intelligence/hw06/src/tree.rs new file mode 100644 index 0000000..86982a3 --- /dev/null +++ b/Year 4/Artificial Intelligence/hw06/src/tree.rs @@ -0,0 +1,36 @@ +use crate::probabilities::*; +use crate::data::*; + +pub struct Node { + decision: HashMap, + leaf: Option, +} + +impl Node { + fn new_leaf(value: Events) -> Node { + Node { + decision: HashMap::new(), + leaf: Some(value), + } + } + + fn new_node() -> Node { + Node { + decision: HashMap::new(), + leaf: None, + } + } +} + +pub struct Tree { + root: Node, +} + +impl Tree { + pub fn new(sample: Vec, features: Vec) -> Tree { + let max_feature = features + .into_iter() + .max_by(|x, y| gain(sample, x).cmp(gain(sample, y))); + let root = Node::new_node(); + } +} -- cgit v1.3.1-26-gb76a