Summary Files Commits Branches @commit @diff @stats
path: root / Year 4 / Artificial Intelligence / hw06 / src / tree.rs
diff options
context:
space:
mode:
1 files changed, 36 insertions, 0 deletions
-rw-r--r--Year 4/Artificial Intelligence/hw06/src/tree.rs36
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();
+ }
+}