Summary Files Commits Branches @commit @diff @stats
path: root / Year 4 / Artificial Intelligence / hw06 / src / tree.rs
blob: 86982a3f349ab0c96f98df690402b14f2cd21e97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::probabilities::*;
use crate::data::*;

pub struct Node<T> {
    decision: HashMap<T, Node>,
    leaf: Option<Events>,
}

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<Person>, features: Vec<string>) -> Tree {
        let max_feature = features
            .into_iter()
            .max_by(|x, y| gain(sample, x).cmp(gain(sample, y)));
        let root = Node::new_node();
    }
}