rmds 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +27 -0
- data/README.md +157 -0
- data/Rakefile +77 -0
- data/examples/adaptive_backend.rb +61 -0
- data/examples/extended_metric.rb +82 -0
- data/examples/minimal_metric.rb +52 -0
- data/examples/visualization.rb +75 -0
- data/examples/visualization_cities.rb +84 -0
- data/lib/mds.rb +22 -0
- data/lib/mds/backend.rb +105 -0
- data/lib/mds/interfaces/gsl_interface.rb +140 -0
- data/lib/mds/interfaces/linalg_interface.rb +149 -0
- data/lib/mds/interfaces/stdlib_interface.rb +155 -0
- data/lib/mds/io.rb +29 -0
- data/lib/mds/matrix.rb +258 -0
- data/lib/mds/matrix_interface.rb +358 -0
- data/lib/mds/metric.rb +150 -0
- data/lib/mds/test/bundles/bundle_matrix_interface.rb +199 -0
- data/lib/mds/test/bundles/bundle_metric.rb +82 -0
- data/lib/mds/test/matrix_assertions.rb +54 -0
- data/test/benchmark/benchmark_metric.rb +53 -0
- data/test/test_helper.rb +11 -0
- data/test/unit/dummy_interfaces.rb +20 -0
- data/test/unit/test_backend.rb +44 -0
- data/test/unit/test_gsl_interface.rb +22 -0
- data/test/unit/test_gsl_metric.rb +22 -0
- data/test/unit/test_linalg_interface.rb +22 -0
- data/test/unit/test_linalg_metric.rb +21 -0
- data/test/unit/test_stdlib_interface.rb +22 -0
- data/test/unit/test_stdlib_metric.rb +21 -0
- metadata +101 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'benchmark'
|
8
|
+
|
9
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
10
|
+
require 'mds'
|
11
|
+
require 'mds/interfaces/gsl_interface'
|
12
|
+
require 'mds/interfaces/stdlib_interface'
|
13
|
+
require 'mds/interfaces/linalg_interface'
|
14
|
+
|
15
|
+
def run_benchmark(b, obs, dims)
|
16
|
+
x = nil; d = nil; proj = nil
|
17
|
+
puts
|
18
|
+
b.report(" create") {x = MDS::Matrix.create_random(obs, dims)}
|
19
|
+
b.report(" sq-dist") {d = MDS::Metric.squared_distances(x)}
|
20
|
+
b.report(" mds") {proj = MDS::Metric.projectd(d, dims)}
|
21
|
+
printf " >total "
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
n = 10
|
26
|
+
d = 2
|
27
|
+
puts "-----------------"
|
28
|
+
puts "Benchmarking RMDS for #{n} observations in #{d}-dimensional space"
|
29
|
+
Benchmark.bm(10) do |x|
|
30
|
+
x.report("stdlib:") {MDS::Backend.active = MDS::StdlibInterface; run_benchmark(x,n,d)}
|
31
|
+
x.report("gsl:") {MDS::Backend.active = MDS::GSLInterface; run_benchmark(x,n,d)}
|
32
|
+
x.report("linalg:") {MDS::Backend.active = MDS::LinalgInterface; run_benchmark(x,n,d)}
|
33
|
+
end
|
34
|
+
|
35
|
+
n = 100
|
36
|
+
d = 5
|
37
|
+
puts "-----------------"
|
38
|
+
puts "Benchmarking RMDS for #{n} observations in #{d}-dimensional space"
|
39
|
+
Benchmark.bm(10) do |x|
|
40
|
+
#x.report("stdlib:") {MDS::Backend.active = MDS::StdlibInterface; run_benchmark(x,n,d)}
|
41
|
+
x.report("gsl:") {MDS::Backend.active = MDS::GSLInterface; run_benchmark(x,n,d)}
|
42
|
+
x.report("linalg:") {MDS::Backend.active = MDS::LinalgInterface; run_benchmark(x,n,d)}
|
43
|
+
end
|
44
|
+
|
45
|
+
n = 1000
|
46
|
+
d = 10
|
47
|
+
puts "-----------------"
|
48
|
+
puts "Benchmarking RMDS for #{n} observations in #{d}-dimensional space"
|
49
|
+
Benchmark.bm(10) do |x|
|
50
|
+
#x.report("stdlib:") {MDS::Backend.active = MDS::StdlibInterface; run_benchmark(x,n,d)}
|
51
|
+
x.report("gsl:") {MDS::Backend.active = MDS::GSLInterface; run_benchmark(x,n,d)}
|
52
|
+
x.report("linalg:") {MDS::Backend.active = MDS::LinalgInterface; run_benchmark(x,n,d)}
|
53
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'mds/matrix_interface'
|
8
|
+
|
9
|
+
module X
|
10
|
+
class DummyInterface0 < MDS::MatrixInterface
|
11
|
+
end
|
12
|
+
|
13
|
+
module Y
|
14
|
+
class DummyInterface1 < MDS::MatrixInterface
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class DummyInterface2 < Y::DummyInterface1
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
|
9
|
+
class TestBackend < Test::Unit::TestCase
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def startup
|
13
|
+
@before = MDS::Backend.available.clone
|
14
|
+
MDS::Backend.available.clear
|
15
|
+
MDS::Backend.try_require('./test/unit/dummy_interfaces.*')
|
16
|
+
end
|
17
|
+
|
18
|
+
def shutdown
|
19
|
+
MDS::Backend.available.clear
|
20
|
+
MDS::Backend.available.concat(@before)
|
21
|
+
end
|
22
|
+
|
23
|
+
def suite
|
24
|
+
mysuite = super
|
25
|
+
def mysuite.run(*args)
|
26
|
+
TestBackend.startup()
|
27
|
+
super
|
28
|
+
TestBackend.shutdown()
|
29
|
+
end
|
30
|
+
mysuite
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_available_interfaces
|
35
|
+
assert_equal([X::DummyInterface0, X::Y::DummyInterface1, X::DummyInterface2], MDS::Backend.available)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_first
|
39
|
+
assert_equal(X::Y::DummyInterface1, MDS::Backend.first(['X::NotHere', 'X::Y::DummyInterface1', 'X::DummyInterface2']))
|
40
|
+
assert_equal(X::DummyInterface0, MDS::Backend.first(['X::NotHere']))
|
41
|
+
assert_equal(X::DummyInterface0, MDS::Backend.first )
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
require 'mds/interfaces/gsl_interface'
|
9
|
+
require 'mds/test/bundles/bundle_matrix_interface.rb'
|
10
|
+
|
11
|
+
class TestGSLInterface < Test::Unit::TestCase
|
12
|
+
include MDS::Test::BundleMatrixInterface
|
13
|
+
|
14
|
+
def setup
|
15
|
+
MDS::Backend.push_active(MDS::GSLInterface)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
MDS::Backend.pop_active
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
require 'mds/test/bundles/bundle_metric.rb'
|
9
|
+
require 'mds/interfaces/gsl_interface'
|
10
|
+
|
11
|
+
class TestGSLMetric < Test::Unit::TestCase
|
12
|
+
include MDS::Test::BundleMetric
|
13
|
+
|
14
|
+
def setup
|
15
|
+
MDS::Backend.push_active(MDS::GSLInterface)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
MDS::Backend.pop_active
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
require 'mds/test/bundles/bundle_matrix_interface.rb'
|
9
|
+
require 'mds/interfaces/linalg_interface'
|
10
|
+
|
11
|
+
class TestLinalgInteface < Test::Unit::TestCase
|
12
|
+
include MDS::Test::BundleMatrixInterface
|
13
|
+
|
14
|
+
def setup
|
15
|
+
MDS::Backend.push_active(MDS::LinalgInterface)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
MDS::Backend.pop_active
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
require 'mds/test/bundles/bundle_metric.rb'
|
9
|
+
require 'mds/interfaces/linalg_interface'
|
10
|
+
|
11
|
+
class TestLinalgMetric < Test::Unit::TestCase
|
12
|
+
include MDS::Test::BundleMetric
|
13
|
+
|
14
|
+
def setup
|
15
|
+
MDS::Backend.push_active(MDS::LinalgInterface)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
MDS::Backend.pop_active
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
require 'mds/test/bundles/bundle_matrix_interface.rb'
|
9
|
+
require 'mds/interfaces/stdlib_interface'
|
10
|
+
|
11
|
+
class TestStdlibInterface < Test::Unit::TestCase
|
12
|
+
include MDS::Test::BundleMatrixInterface
|
13
|
+
|
14
|
+
def setup
|
15
|
+
MDS::Backend.push_active(MDS::StdlibInterface)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
MDS::Backend.pop_active
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# RMDS - Ruby Multidimensional Scaling Library
|
3
|
+
# Copyright (c) Christoph Heindl, 2010
|
4
|
+
# http://github.com/cheind/rmds
|
5
|
+
#
|
6
|
+
|
7
|
+
require './test/test_helper.rb'
|
8
|
+
require 'mds/test/bundles/bundle_metric.rb'
|
9
|
+
require 'mds/interfaces/stdlib_interface'
|
10
|
+
|
11
|
+
class TestStdlibMetric < Test::Unit::TestCase
|
12
|
+
include MDS::Test::BundleMetric
|
13
|
+
|
14
|
+
def setup
|
15
|
+
MDS::Backend.push_active(MDS::StdlibInterface)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
MDS::Backend.pop_active
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rmds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.2"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christoph Heindl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-09-22 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Multidimensional scaling (MDS) is a set of related statistical techniques often used in information visualization for exploring similarities or dissimilarities in data.
|
17
|
+
email: christoph.heindl@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.md
|
24
|
+
- LICENSE.md
|
25
|
+
files:
|
26
|
+
- LICENSE.md
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- lib/mds/backend.rb
|
30
|
+
- lib/mds/interfaces/gsl_interface.rb
|
31
|
+
- lib/mds/interfaces/stdlib_interface.rb
|
32
|
+
- lib/mds/interfaces/linalg_interface.rb
|
33
|
+
- lib/mds/metric.rb
|
34
|
+
- lib/mds/io.rb
|
35
|
+
- lib/mds/matrix.rb
|
36
|
+
- lib/mds/matrix_interface.rb
|
37
|
+
- lib/mds/test/matrix_assertions.rb
|
38
|
+
- lib/mds/test/bundles/bundle_metric.rb
|
39
|
+
- lib/mds/test/bundles/bundle_matrix_interface.rb
|
40
|
+
- lib/mds.rb
|
41
|
+
- test/unit/test_gsl_interface.rb
|
42
|
+
- test/unit/dummy_interfaces.rb
|
43
|
+
- test/unit/test_gsl_metric.rb
|
44
|
+
- test/unit/test_linalg_interface.rb
|
45
|
+
- test/unit/test_backend.rb
|
46
|
+
- test/unit/test_stdlib_metric.rb
|
47
|
+
- test/unit/test_stdlib_interface.rb
|
48
|
+
- test/unit/test_linalg_metric.rb
|
49
|
+
- test/benchmark/benchmark_metric.rb
|
50
|
+
- test/test_helper.rb
|
51
|
+
- examples/adaptive_backend.rb
|
52
|
+
- examples/visualization.rb
|
53
|
+
- examples/extended_metric.rb
|
54
|
+
- examples/visualization_cities.rb
|
55
|
+
- examples/minimal_metric.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/cheind/rmds
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --title
|
63
|
+
- RMDS v0.2 -- Ruby Multidimensional Scaling Library
|
64
|
+
- --main
|
65
|
+
- README.md
|
66
|
+
- -x
|
67
|
+
- test/*
|
68
|
+
- -x
|
69
|
+
- examples/*
|
70
|
+
require_paths:
|
71
|
+
- ./lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
requirements: []
|
85
|
+
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.3.5
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Ruby Multidimensional Scaling Library
|
91
|
+
test_files:
|
92
|
+
- test/unit/test_gsl_interface.rb
|
93
|
+
- test/unit/dummy_interfaces.rb
|
94
|
+
- test/unit/test_gsl_metric.rb
|
95
|
+
- test/unit/test_linalg_interface.rb
|
96
|
+
- test/unit/test_backend.rb
|
97
|
+
- test/unit/test_stdlib_metric.rb
|
98
|
+
- test/unit/test_stdlib_interface.rb
|
99
|
+
- test/unit/test_linalg_metric.rb
|
100
|
+
- test/benchmark/benchmark_metric.rb
|
101
|
+
- test/test_helper.rb
|