umappp 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 652d8cf10c9054b45a567638d8f04f42f8915944bc980c6e28b9e71f0a0f76af
4
- data.tar.gz: 2d9f36babd30db2554e6e02753d16d777dabcb2c163f1558f369035317fd1398
3
+ metadata.gz: cc70f43249cb1993d3fdb810a0cc542e9da383c113f3119414c43723e613ccf0
4
+ data.tar.gz: ec95857557261b5d1aa066dae830ffb7648e7758dd50a96c14af5332a2563e9f
5
5
  SHA512:
6
- metadata.gz: 45fe9afc8e8a0917429901ee7cfca09596a4ec6d3e292717aa2035f0ba992e570da604bd22879abfc924ff75e200e2d37513ed82ab7b8d547df9234d025a8429
7
- data.tar.gz: 267b65e8883f039e1876a4b4b629cd77b506212641d602bf97f1787103b99457148618188dd6aafdb5c8d96df1e22fa2a2dc0d73a052d4375c6b731288532784
6
+ metadata.gz: b0d0be70caca251226572ae920adab0938451383a90444235ffd939ad23e58c73034cdce95fa4639d26da9f5517453f0aa2b78fcb8d254d03685726b55ceb10d
7
+ data.tar.gz: 4cebd1fb124c6d61bf083af58283f75a9e6a714c2ad4425a2c72871fa1bee579bb7377859691187ecfb6f845d6e2b8d4bb670e1837813fe7e6dbb33975aa2c70
data/README.md CHANGED
@@ -28,10 +28,12 @@ gem install umappp
28
28
  This Gem provides the module `Umappp` and its singular method `Umappp.run()`. The first argument of `Umappp.run()` is a two-dimensional Ruby array or a two-dimensional Numo array. [Numo](https://github.com/ruby-numo/numo-narray) is a library for performing N-dimensional array computing like NumPy. The argument is converted to `Numo::SFloat`. SFloat is a single precision floating point number type of Numo::NArray.
29
29
 
30
30
  ```ruby
31
- Umappp.run(embedding) # embedding is two-dimensional Ruby array or Numo array
31
+ # The embedding is two-dimensional Ruby array or Numo array
32
+ # Returns Numo::SFloat
33
+ r = Umappp.run(embedding)
32
34
 
33
- # with parameters
34
- Umappp.run(pixels, num_threads: 8, a: 1.8956, b: 0.8006)
35
+ # Run with parameters
36
+ r = Umappp.run(pixels, num_threads: 8, a: 1.8956, b: 0.8006)
35
37
  ```
36
38
 
37
39
  Available parameters and their default values
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Umappp
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/umappp.rb CHANGED
@@ -6,7 +6,6 @@ require_relative "umappp/umappp"
6
6
 
7
7
  # Uniform Manifold Approximation and Projection
8
8
  module Umappp
9
-
10
9
  # Make wrapper methods for the C++ function generated by Rice private
11
10
  private_class_method :umappp_run
12
11
  private_class_method :umappp_default_parameters
@@ -17,9 +16,9 @@ module Umappp
17
16
  umappp_default_parameters
18
17
  end
19
18
 
20
- # Runs the Uniform Manifold Approximation and Projection (UMAP) dimensional
21
- # reduction technique.
22
- # @param embedding [Array, Numo::SFloat]
19
+ # Runs the Uniform Manifold Approximation and Projection (UMAP) dimensional
20
+ # reduction technique.
21
+ # @param embedding [Array, Numo::SFloat]
23
22
  # @param method [Symbol]
24
23
  # @param ndim [Integer]
25
24
  # @param tick [Integer]
@@ -38,6 +37,7 @@ module Umappp
38
37
  # @param seed [Integer]
39
38
  # @param batch [Boolean]
40
39
  # @param num_threads [Integer]
40
+ # @return [Numo::SFloat] the final embedding
41
41
 
42
42
  def self.run(embedding, method: :annoy, ndim: 2, tick: 0, **params)
43
43
  unless (u = (params.keys - default_parameters.keys)).empty?
@@ -45,8 +45,11 @@ module Umappp
45
45
  end
46
46
 
47
47
  nnmethod = %i[annoy vptree].index(method.to_sym)
48
- data = Numo::SFloat.cast(embedding)
48
+ raise ArgumentError, "method must be :annoy or :vptree" if nnmethod.nil?
49
+
50
+ embedding2 = Numo::SFloat.cast(embedding)
51
+ raise ArgumentError, "embedding must be a 2D array" if embedding2.ndim <= 1
49
52
 
50
- umappp_run(params, data, ndim, nnmethod, tick)
53
+ umappp_run(params, embedding2, ndim, nnmethod, tick)
51
54
  end
52
55
  end
@@ -1,6 +1,9 @@
1
1
  #ifndef UMAPPP_NEIGHBOR_LIST_HPP
2
2
  #define UMAPPP_NEIGHBOR_LIST_HPP
3
3
 
4
+ #include <utility>
5
+ #include <vector>
6
+
4
7
  /**
5
8
  * @file NeighborList.hpp
6
9
  *
@@ -38,7 +38,7 @@ enum InitMethod { SPECTRAL, SPECTRAL_ONLY, RANDOM, NONE };
38
38
  /**
39
39
  * @cond
40
40
  */
41
- int choose_num_epochs(int num_epochs, size_t size) {
41
+ inline int choose_num_epochs(int num_epochs, size_t size) {
42
42
  if (num_epochs < 0) {
43
43
  // Choosing the number of epochs. We use a simple formula to decrease
44
44
  // the number of epochs with increasing size, with the aim being that
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umappp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray