Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "./version.cr"
- require "json"
- module ID3 extend self
- # A decision tree class which consists of a recursive set of decision tree nodes.
- class Tree
- # Initializes the decision tree.
- #
- # **Arguments**:
- #
- # `training`
- # - A `JSON::Any` object of the training set
- #
- # `d`
- # - The index of dependent variable in the attribute list
- def initialize(@training : JSON::Any, d = -1)
- dependent = @training["attributes"][d]
- attributes = @training["attributes"].as_a
- attributes.delete_at(d)
- data = @training["data"]
- puts dependent
- puts attributes
- end
- end
- def retr_json(path)
- File.open(path) do |file|
- JSON.parse(file)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement