Sha256: dff88d3930e32889b9854a80678eebef95493a76ed3decdeb976c0863836e70d
Contents?: true
Size: 762 Bytes
Versions: 4
Compression:
Stored size: 762 Bytes
Contents
module DbClustering module DatasourceAdapters class ActiveRecord def initialize(relation:) @relation = relation end def iterate_all_points @relation.find_each do |datasource_point| point = DbClustering::Models::Point.new(datasource_point) yield(point) end end def neighbors(point:, distance_metric:, max_distance:) neighbors = [] @relation.find_each do |neighbor_candidate| candidate_point = DbClustering::Models::Point.new(neighbor_candidate) if distance_metric.distance(point.vector, candidate_point.vector) <= max_distance neighbors << candidate_point end end neighbors end end end end
Version data entries
4 entries across 4 versions & 1 rubygems