liblinear-ruby-swig 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/linear_cv.rb ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'linear'
4
+
5
+ def do_cross_validation(prob_x, prob_y, param, nr_fold)
6
+ puts "Do cross validation for a given Linear problem."
7
+ prob_l = prob_y.size
8
+ total_correct = 0
9
+ total_error = sumv = sumy = sumvv = sumyy = sumvy = 0.0
10
+ prob = LProblem.new(prob_y, prob_x, 0)
11
+ target = cross_validation(prob, param, nr_fold)
12
+ for i in (0..prob_l-1)
13
+ if false
14
+ v = target[i]
15
+ y = prob_y[i]
16
+ sumv = sumv + v
17
+ sumy = sumy + y
18
+ sumvv = sumvv + v * v
19
+ sumyy = sumyy + y * y
20
+ sumvy = sumvy + v * y
21
+ total_error = total_error + (v-y) * (v-y)
22
+ else
23
+ v = target[i]
24
+ if v == prob_y[i]
25
+ total_correct = total_correct + 1
26
+ end
27
+ end
28
+ end
29
+
30
+ if false
31
+ puts "Cross Validation Mean squared error = #{total_error / prob_l}"
32
+ puts "Cross Validation Squared correlation coefficient = #{((prob_l * sumvy - sumv * sumy) * (prob_l * sumvy - sumv * sumy)) / ((prob_l * sumvv - sumv * sumv) * (prob_l * sumyy - sumy * sumy))}"
33
+ else
34
+ puts "Cross Validation Accuracy = #{100.0 * total_correct / prob_l}%"
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liblinear-ruby-swig
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Tom Zeng
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-27 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hoe
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 8
30
+ - 3
31
+ version: 1.8.3
32
+ type: :development
33
+ version_requirements: *id001
34
+ description: Ruby wrapper of LIBLINEAR using SWIG
35
+ email: tom.z.zeng@gmail.com
36
+ executables: []
37
+
38
+ extensions:
39
+ - ext/extconf.rb
40
+ extra_rdoc_files:
41
+ - History.txt
42
+ - Manifest.txt
43
+ - README.rdoc
44
+ files:
45
+ - History.txt
46
+ - COPYING
47
+ - AUTHORS
48
+ - Manifest.txt
49
+ - README.rdoc
50
+ - Rakefile
51
+ - lib/linear.rb
52
+ - lib/linear_cv.rb
53
+ - ext/liblinear_wrap.cxx
54
+ - ext/linear.cpp
55
+ - ext/linear.h
56
+ - ext/extconf.rb
57
+ - ext/tron.h
58
+ - ext/tron.cpp
59
+ - ext/blas.h
60
+ - ext/blasp.h
61
+ - ext/dscal.c
62
+ - ext/dnrm2.c
63
+ - ext/ddot.c
64
+ - ext/daxpy.c
65
+ has_rdoc: true
66
+ homepage: http://www.tomzconsulting.com
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --main
72
+ - README.rdoc
73
+ require_paths:
74
+ - lib
75
+ - ext
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.3.6
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: Ruby wrapper of LIBLINEAR using SWIG
97
+ test_files: []
98
+