tsne 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +9 -9
- data/README.md +60 -9
- data/lib/tsne/ffi.rb +6 -1
- data/lib/tsne/model.rb +9 -1
- data/lib/tsne/version.rb +1 -1
- data/lib/tsne.rb +12 -4
- data/vendor/LICENSE-bhtsne.txt +27 -0
- data/vendor/{LICENSE.txt → LICENSE-multicore-tsne.txt} +8 -2
- data/vendor/libtsne_multicore.arm64.dylib +0 -0
- data/vendor/libtsne_multicore.arm64.so +0 -0
- data/vendor/libtsne_multicore.dylib +0 -0
- metadata +15 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6177e34d45d9b497d74bb427bd827711d56094e6db6d843fd68615681f71b439
|
4
|
+
data.tar.gz: 76b7ddfec095f30da9d7eedb6298b00fce4bb8fd1fb082573ab3e84df987c670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae6d02f9dfce831fac8c4072fc28994b4bce38f3882418752521ae7836f29a130e0f814aaff050cd77251c17cece6d8331e0694d5ebea81e395fe96232717d87
|
7
|
+
data.tar.gz: fd771ca10c5f3fc4a2730312ba355c7fdb11471751cba459a84b41650321b9d9b293f6de2a903cb05e750af01e87c0f2ef4b0cfc262ab6006c861e9a9e18b5f9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.2.0 (2023-05-11)
|
2
|
+
|
3
|
+
- Added ARM shared libraries
|
4
|
+
- Added support for OpenMP on Mac
|
5
|
+
- Added support for boolean values to `verbose` option
|
6
|
+
- Dropped support for Ruby < 3
|
7
|
+
|
1
8
|
## 0.1.1 (2020-02-11)
|
2
9
|
|
3
10
|
- Fixed `Could not find Multicore t-SNE` error on some Linux platforms
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
BSD 3-Clause License
|
2
2
|
|
3
|
-
Copyright (c) 2020, Andrew Kane
|
3
|
+
Copyright (c) 2020-2023, Andrew Kane
|
4
4
|
All rights reserved.
|
5
5
|
|
6
6
|
Redistribution and use in source and binary forms, with or without
|
7
7
|
modification, are permitted provided that the following conditions are met:
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
19
19
|
|
20
20
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
21
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/README.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
# t-SNE
|
1
|
+
# t-SNE Ruby
|
2
2
|
|
3
|
-
High performance t-SNE for Ruby, powered by [Multicore t-SNE](https://github.com/DmitryUlyanov/
|
3
|
+
High performance t-SNE for Ruby, powered by [Multicore t-SNE](https://github.com/DmitryUlyanov/Multicore-TSNE)
|
4
|
+
|
5
|
+
[![Build Status](https://github.com/ankane/tsne-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/tsne-ruby/actions)
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application’s Gemfile:
|
8
10
|
|
9
11
|
```ruby
|
10
|
-
gem
|
12
|
+
gem "tsne"
|
13
|
+
```
|
14
|
+
|
15
|
+
On Mac, also install OpenMP:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
brew install libomp
|
11
19
|
```
|
12
20
|
|
13
21
|
## Getting Started
|
@@ -15,7 +23,7 @@ gem 'tsne'
|
|
15
23
|
Prep your data
|
16
24
|
|
17
25
|
```ruby
|
18
|
-
x =
|
26
|
+
x = [[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]
|
19
27
|
```
|
20
28
|
|
21
29
|
Run
|
@@ -31,6 +39,35 @@ Get Kullback-Leibler divergence
|
|
31
39
|
tsne.kl_divergence
|
32
40
|
```
|
33
41
|
|
42
|
+
## Full Example
|
43
|
+
|
44
|
+
Install the [matplotlib](https://github.com/mrkn/matplotlib.rb) gem and download the [optdigits.tes](https://archive.ics.uci.edu/ml/machine-learning-databases/optdigits/optdigits.tes) from the [Optical Recognition of Handwritten Digits Data Set](https://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits).
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require "csv"
|
48
|
+
require "matplotlib/pyplot"
|
49
|
+
require "tsne"
|
50
|
+
|
51
|
+
data = []
|
52
|
+
target = []
|
53
|
+
CSV.foreach("optdigits.tes", converters: :numeric) do |row|
|
54
|
+
data << row[0...-1]
|
55
|
+
target << row[-1]
|
56
|
+
end
|
57
|
+
|
58
|
+
tsne = TSNE.new(n_jobs: 4)
|
59
|
+
embeddings = tsne.fit_transform(data)
|
60
|
+
|
61
|
+
vis_x = embeddings[true, 0]
|
62
|
+
vis_y = embeddings[true, 1]
|
63
|
+
|
64
|
+
plt = Matplotlib::Pyplot
|
65
|
+
plt.scatter(vis_x.to_a, vis_y.to_a, c: target, cmap: plt.cm.get_cmap("jet", 10), marker: ".")
|
66
|
+
plt.colorbar(ticks: 10.times.to_a)
|
67
|
+
plt.clim(-0.5, 9.5)
|
68
|
+
plt.show
|
69
|
+
```
|
70
|
+
|
34
71
|
## Parameters
|
35
72
|
|
36
73
|
```ruby
|
@@ -49,24 +86,38 @@ TSNE.new(
|
|
49
86
|
)
|
50
87
|
```
|
51
88
|
|
89
|
+
## Data
|
90
|
+
|
91
|
+
Data can be a Ruby array
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
[[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]
|
95
|
+
```
|
96
|
+
|
97
|
+
Or a Numo array
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
Numo::DFloat.new(4, 3).rand
|
101
|
+
```
|
102
|
+
|
52
103
|
## History
|
53
104
|
|
54
|
-
View the [changelog](https://github.com/ankane/tsne/blob/master/CHANGELOG.md)
|
105
|
+
View the [changelog](https://github.com/ankane/tsne-ruby/blob/master/CHANGELOG.md)
|
55
106
|
|
56
107
|
## Contributing
|
57
108
|
|
58
109
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
59
110
|
|
60
|
-
- [Report bugs](https://github.com/ankane/tsne/issues)
|
61
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/tsne/pulls)
|
111
|
+
- [Report bugs](https://github.com/ankane/tsne-ruby/issues)
|
112
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/tsne-ruby/pulls)
|
62
113
|
- Write, clarify, or fix documentation
|
63
114
|
- Suggest or add new features
|
64
115
|
|
65
116
|
To get started with development:
|
66
117
|
|
67
118
|
```sh
|
68
|
-
git clone https://github.com/ankane/tsne.git
|
69
|
-
cd tsne
|
119
|
+
git clone https://github.com/ankane/tsne-ruby.git
|
120
|
+
cd tsne-ruby
|
70
121
|
bundle install
|
71
122
|
bundle exec rake vendor:all
|
72
123
|
bundle exec rake test
|
data/lib/tsne/ffi.rb
CHANGED
@@ -7,7 +7,12 @@ module TSNE
|
|
7
7
|
dlload Fiddle.dlopen(libs.shift)
|
8
8
|
rescue Fiddle::DLError => e
|
9
9
|
retry if libs.any?
|
10
|
-
|
10
|
+
|
11
|
+
if e.message =~ /Library not loaded: .+libomp/
|
12
|
+
raise LoadError, "OpenMP not found. Run `brew install libomp`"
|
13
|
+
else
|
14
|
+
raise e
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
typealias "bool", "char"
|
data/lib/tsne/model.rb
CHANGED
@@ -13,7 +13,15 @@ module TSNE
|
|
13
13
|
@learning_rate = learning_rate
|
14
14
|
@n_iter = n_iter
|
15
15
|
@n_iter_early_exag = n_iter_early_exag
|
16
|
-
@verbose =
|
16
|
+
@verbose =
|
17
|
+
case verbose
|
18
|
+
when true
|
19
|
+
1
|
20
|
+
when false
|
21
|
+
0
|
22
|
+
else
|
23
|
+
verbose
|
24
|
+
end
|
17
25
|
@random_state = random_state
|
18
26
|
@angle = angle
|
19
27
|
@n_jobs = n_jobs
|
data/lib/tsne/version.rb
CHANGED
data/lib/tsne.rb
CHANGED
@@ -5,8 +5,8 @@ require "numo/narray"
|
|
5
5
|
require "fiddle/import"
|
6
6
|
|
7
7
|
# modules
|
8
|
-
|
9
|
-
|
8
|
+
require_relative "tsne/model"
|
9
|
+
require_relative "tsne/version"
|
10
10
|
|
11
11
|
module TSNE
|
12
12
|
class Error < StandardError; end
|
@@ -18,9 +18,17 @@ module TSNE
|
|
18
18
|
if Gem.win_platform?
|
19
19
|
"tsne_multicore.dll"
|
20
20
|
elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
|
21
|
-
"
|
21
|
+
if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
|
22
|
+
"libtsne_multicore.arm64.dylib"
|
23
|
+
else
|
24
|
+
"libtsne_multicore.dylib"
|
25
|
+
end
|
22
26
|
else
|
23
|
-
"
|
27
|
+
if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
|
28
|
+
"libtsne_multicore.arm64.so"
|
29
|
+
else
|
30
|
+
"libtsne_multicore.so"
|
31
|
+
end
|
24
32
|
end
|
25
33
|
vendor_lib = File.expand_path("../vendor/#{lib_name}", __dir__)
|
26
34
|
self.ffi_lib = [vendor_lib]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2014, Laurens van der Maaten (Delft University of Technology)
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
3. All advertising materials mentioning features or use of this software
|
12
|
+
must display the following acknowledgement:
|
13
|
+
This product includes software developed by the Delft University of Technology.
|
14
|
+
4. Neither the name of the Delft University of Technology nor the names of
|
15
|
+
its contributors may be used to endorse or promote products derived from
|
16
|
+
this software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY LAURENS VAN DER MAATEN ''AS IS'' AND ANY EXPRESS
|
19
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
20
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
21
|
+
EVENT SHALL LAURENS VAN DER MAATEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
23
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
24
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
26
|
+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
27
|
+
OF SUCH DAMAGE.
|
@@ -1,7 +1,13 @@
|
|
1
|
+
Created by Laurens van der Maaten.
|
2
|
+
Copyright 2012, Delft University of Technology. All rights reserved.
|
3
|
+
|
4
|
+
Multicore version by Dmitry Ulyanov, 2016. dmitry.ulyanov.msu@gmail.com
|
5
|
+
|
6
|
+
--------------------------------------------------------------------------------
|
7
|
+
|
1
8
|
BSD 3-Clause License
|
2
9
|
|
3
|
-
Copyright (c)
|
4
|
-
Copyright (c) 2016, Dmitry Ulyanov
|
10
|
+
Copyright (c) [year], [fullname]
|
5
11
|
All rights reserved.
|
6
12
|
|
7
13
|
Redistribution and use in source and binary forms, with or without
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsne
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -24,50 +24,8 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
|
28
|
-
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5'
|
69
|
-
description:
|
70
|
-
email: andrew@chartkick.com
|
27
|
+
description:
|
28
|
+
email: andrew@ankane.org
|
71
29
|
executables: []
|
72
30
|
extensions: []
|
73
31
|
extra_rdoc_files: []
|
@@ -79,15 +37,18 @@ files:
|
|
79
37
|
- lib/tsne/ffi.rb
|
80
38
|
- lib/tsne/model.rb
|
81
39
|
- lib/tsne/version.rb
|
82
|
-
- vendor/LICENSE.txt
|
40
|
+
- vendor/LICENSE-bhtsne.txt
|
41
|
+
- vendor/LICENSE-multicore-tsne.txt
|
42
|
+
- vendor/libtsne_multicore.arm64.dylib
|
43
|
+
- vendor/libtsne_multicore.arm64.so
|
83
44
|
- vendor/libtsne_multicore.dylib
|
84
45
|
- vendor/libtsne_multicore.so
|
85
46
|
- vendor/tsne_multicore.dll
|
86
|
-
homepage: https://github.com/ankane/tsne
|
47
|
+
homepage: https://github.com/ankane/tsne-ruby
|
87
48
|
licenses:
|
88
|
-
-
|
49
|
+
- BSD-3-Clause
|
89
50
|
metadata: {}
|
90
|
-
post_install_message:
|
51
|
+
post_install_message:
|
91
52
|
rdoc_options: []
|
92
53
|
require_paths:
|
93
54
|
- lib
|
@@ -95,15 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
56
|
requirements:
|
96
57
|
- - ">="
|
97
58
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
59
|
+
version: '3'
|
99
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
61
|
requirements:
|
101
62
|
- - ">="
|
102
63
|
- !ruby/object:Gem::Version
|
103
64
|
version: '0'
|
104
65
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
66
|
+
rubygems_version: 3.4.10
|
67
|
+
signing_key:
|
107
68
|
specification_version: 4
|
108
69
|
summary: High performance t-SNE for Ruby
|
109
70
|
test_files: []
|