Class: DbClustering::Models::Point
- Inherits:
-
Object
- Object
- DbClustering::Models::Point
- Defined in:
- lib/models/point.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#datasource_point ⇒ Object
Returns the value of attribute datasource_point.
-
#is_noise ⇒ Object
Returns the value of attribute is_noise.
Instance Method Summary collapse
-
#initialize(datasource_point:, vector_params: nil) ⇒ Point
constructor
A new instance of Point.
- #is_core_point? ⇒ Boolean
- #is_edge_point? ⇒ Boolean
- #is_noise_point? ⇒ Boolean
- #vector ⇒ Object
- #visited? ⇒ Boolean
Constructor Details
#initialize(datasource_point:, vector_params: nil) ⇒ Point
Returns a new instance of Point.
7 8 9 10 11 12 |
# File 'lib/models/point.rb', line 7 def initialize(datasource_point:, vector_params: nil) @is_noise = false @cluster = nil @datasource_point = datasource_point @vector_params = vector_params end |
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
5 6 7 |
# File 'lib/models/point.rb', line 5 def cluster @cluster end |
#datasource_point ⇒ Object
Returns the value of attribute datasource_point.
5 6 7 |
# File 'lib/models/point.rb', line 5 def datasource_point @datasource_point end |
#is_noise ⇒ Object
Returns the value of attribute is_noise.
5 6 7 |
# File 'lib/models/point.rb', line 5 def is_noise @is_noise end |
Instance Method Details
#is_core_point? ⇒ Boolean
36 37 38 |
# File 'lib/models/point.rb', line 36 def is_core_point? !self.is_noise && !self.cluster.nil? end |
#is_edge_point? ⇒ Boolean
32 33 34 |
# File 'lib/models/point.rb', line 32 def is_edge_point? self.is_noise && !self.cluster.nil? end |
#is_noise_point? ⇒ Boolean
40 41 42 |
# File 'lib/models/point.rb', line 40 def is_noise_point? self.is_noise && self.cluster.nil? end |
#vector ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/models/point.rb', line 14 def vector if @vector_params vector_object = @datasource_point.clustering_vector(@vector_params) else vector_object = @datasource_point.clustering_vector end if vector_object.is_a?(Hash) || vector_object.is_a?(Array) DbClustering::Models::Vector.new(object: vector_object) else raise "clustering_vector method needs to result to a Hash or an Array object" end end |
#visited? ⇒ Boolean
28 29 30 |
# File 'lib/models/point.rb', line 28 def visited? self.is_noise || !self.cluster.nil? end |