diff options
hw(AI/6): Progress
1 files changed, 36 insertions, 0 deletions
| -rw-r--r-- | Year 4/Artificial Intelligence/hw06/src/tree.rs | 36 |
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<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(); + } +} |
