lib/umappp.rb in umappp-0.1.2 vs lib/umappp.rb in umappp-0.1.3

- old
+ new

@@ -5,11 +5,22 @@ require_relative "umappp/umappp" # Uniform Manifold Approximation and Projection module Umappp - # Run UMAP + # Make wrapper methods for the C++ function generated by Rice private + private_class_method :umappp_run + private_class_method :umappp_default_parameters + + # View the default parameters defined within the Umappp C++ library structure. + def self.default_parameters + # {method: :annoy, ndim: 2, tick: 0}.merge + umappp_default_parameters + end + + # Runs the Uniform Manifold Approximation and Projection (UMAP) dimensional + # reduction technique. # @param embedding [Array, Numo::SFloat] # @param method [Symbol] # @param ndim [Integer] # @param tick [Integer] # @param local_connectivity [Numeric] @@ -26,16 +37,16 @@ # @param num_neighbors [Integer] # @param seed [Integer] # @param batch [Boolean] # @param num_threads [Integer] - def self.run(ary, method: :annoy, ndim: 2, tick: 0, **params) + def self.run(embedding, method: :annoy, ndim: 2, tick: 0, **params) unless (u = (params.keys - default_parameters.keys)).empty? raise ArgumentError, "[umappp.rb] unknown option : #{u.inspect}" end nnmethod = %i[annoy vptree].index(method.to_sym) - data = Numo::SFloat.cast(ary) + data = Numo::SFloat.cast(embedding) - Umappp.umap_run(params, data, ndim, nnmethod, tick) + umappp_run(params, data, ndim, nnmethod, tick) end end