Advertisement
Guest User

Untitled

a guest
May 11th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. require "./version.cr"
  2. require "json"
  3.  
  4. module ID3 extend self
  5. # A decision tree class which consists of a recursive set of decision tree nodes.
  6. class Tree
  7. # Initializes the decision tree.
  8. #
  9. # **Arguments**:
  10. #
  11. # `training`
  12. # - A `JSON::Any` object of the training set
  13. #
  14. # `d`
  15. # - The index of dependent variable in the attribute list
  16. def initialize(@training : JSON::Any, d = -1)
  17. dependent = @training["attributes"][d]
  18.  
  19. attributes = @training["attributes"].as_a
  20. attributes.delete_at(d)
  21.  
  22. data = @training["data"]
  23.  
  24. puts dependent
  25. puts attributes
  26. end
  27. end
  28.  
  29. def retr_json(path)
  30. File.open(path) do |file|
  31. JSON.parse(file)
  32. end
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement