Class: SameSame::SimilarityMatrix
- Inherits:
-
Object
- Object
- SameSame::SimilarityMatrix
- Defined in:
- lib/same_same/similarity_matrix.rb
Instance Attribute Summary collapse
-
#datapoints ⇒ Object
readonly
Returns the value of attribute datapoints.
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
-
#measure ⇒ Object
readonly
Returns the value of attribute measure.
Instance Method Summary collapse
-
#initialize(measure, datapoints) ⇒ SimilarityMatrix
constructor
A new instance of SimilarityMatrix.
- #lookup(i, j) ⇒ Object
Constructor Details
#initialize(measure, datapoints) ⇒ SimilarityMatrix
Returns a new instance of SimilarityMatrix.
5 6 7 8 9 |
# File 'lib/same_same/similarity_matrix.rb', line 5 def initialize( measure, datapoints ) @matrix = SymmetricalMatrix.new( datapoints.size ) @measure = measure @datapoints = datapoints end |
Instance Attribute Details
#datapoints ⇒ Object (readonly)
Returns the value of attribute datapoints.
3 4 5 |
# File 'lib/same_same/similarity_matrix.rb', line 3 def datapoints @datapoints end |
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
3 4 5 |
# File 'lib/same_same/similarity_matrix.rb', line 3 def matrix @matrix end |
#measure ⇒ Object (readonly)
Returns the value of attribute measure.
3 4 5 |
# File 'lib/same_same/similarity_matrix.rb', line 3 def measure @measure end |
Instance Method Details
#lookup(i, j) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/same_same/similarity_matrix.rb', line 11 def lookup(i,j) return 1.0 if i == j matrix.lookup(i,j) do |x,y| measure.similarity( datapoints[x], datapoints[y]) end end |