liblinear-ruby 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 80d838932a4299e6a989377e7d73f46c3718eeff
4
- data.tar.gz: 03f5be533321002f919b025ba611200bf58244fb
3
+ metadata.gz: 5627682e3eced50c405c213569f4c18f178bd6a5
4
+ data.tar.gz: abdf3297770c99e176b26a74c34d2e2c4eb03de1
5
5
  SHA512:
6
- metadata.gz: 6ce90555ad269328c7d9f632ffcf6c2341359ec7d13c85f80dcefddda6a29c8627fa2a4256a34bbdd403ef20f569b4582bdbe54b7d51bd43a7e8f619dc32b67a
7
- data.tar.gz: f91a4dcdd15a628f5bc7e0f579f519d9f6d8b6513584f85fba2228feac8f66e6fade77ffddaca0a138bac49cdcfe646aba832aba52f98eaf94f14b712b79133b
6
+ metadata.gz: 71443f67c21c93fbafd8031554045db2b8bdeddd2574b5dc582bf7cd034f5725c2bfe2acf56706fb5b07f5e82b598b43b2595619e14889c7ca913136668bf1ee
7
+ data.tar.gz: c85b14d11e5a858297826747c49a890ef60e63531750be77cb403cfc3543ca294d440dafa084d25752801387a351cd7da9d7cca8277846345de30b0bb9d02e2e
data/.gitignore CHANGED
@@ -8,6 +8,7 @@ InstalledFiles
8
8
  _yardoc
9
9
  coverage
10
10
  doc/
11
+ ext/Makefile
11
12
  ext/*.o
12
13
  ext/*.so
13
14
  lib/bundler/man
@@ -8,7 +8,6 @@ require 'liblinear/problem'
8
8
  require 'liblinear/version'
9
9
 
10
10
  module Liblinear
11
- #include Liblinearswig
12
11
  # @param ruby_array [Array<Integer>]
13
12
  # @return [SWIG::TYPE_p_int]
14
13
  def new_int_array(ruby_array)
@@ -41,12 +40,14 @@ module Liblinear
41
40
 
42
41
  # @param c_array [SWIG::TYPE_p_int]
43
42
  # @param size [Integer]
43
+ # @return [Array<Integer>]
44
44
  def int_array_c_to_ruby(c_array, size)
45
45
  size.times.map {|index| int_getitem(c_array, index)}
46
46
  end
47
47
 
48
48
  # @param c_array [SWIG::TYPE_p_double]
49
49
  # @param size [Integer]
50
+ # @return [Array<Double>]
50
51
  def double_array_c_to_ruby(c_array, size)
51
52
  size.times.map {|index| double_getitem(c_array, index)}
52
53
  end
@@ -66,7 +67,7 @@ module Liblinear
66
67
  example_indexes << index
67
68
  end
68
69
  else
69
- raise TypeError, 'data must be a Hash or an Array'
70
+ raise TypeError, 'example must be a Hash or an Array'
70
71
  end
71
72
  example_indexes.sort!
72
73
 
@@ -6,6 +6,8 @@ module Liblinear
6
6
 
7
7
  # @param arg_1 [LibLinear::Problem, String]
8
8
  # @param arg_2 [Liblinear::Parameter]
9
+ # @raise [ArgumentError]
10
+ # @raise [Liblinear::InvalidParameter]
9
11
  def initialize(arg_1, arg_2 = nil)
10
12
  if arg_2
11
13
  unless arg_1.is_a?(Liblinear::Problem) && arg_2.is_a?(Liblinear::Parameter)
@@ -20,12 +22,12 @@ module Liblinear
20
22
  end
21
23
  end
22
24
 
23
- # return [Integer]
25
+ # @return [Integer]
24
26
  def nr_class
25
27
  get_nr_class(@model)
26
28
  end
27
29
 
28
- # return [Array<Integer>]
30
+ # @return [Array<Integer>]
29
31
  def labels
30
32
  c_int_array = new_int(nr_class)
31
33
  get_labels(@model, c_int_array)
@@ -35,6 +37,7 @@ module Liblinear
35
37
  end
36
38
 
37
39
  # @param example [Array, Hash]
40
+ # @return [Double]
38
41
  def predict(example)
39
42
  feature_nodes = convert_to_feature_node_array(example, @model.nr_feature, @model.bias)
40
43
  prediction = Liblinearswig.predict(@model, feature_nodes)
@@ -7,6 +7,7 @@ module Liblinear
7
7
  # @param labels [Array<Double>]
8
8
  # @param examples [Array<Double>, Array<Hash>]
9
9
  # @param bias [Double]
10
+ # @raise [ArgumentError]
10
11
  def initialize(labels, examples, bias)
11
12
  unless labels.size == examples.size
12
13
  raise ArgumentError, 'labels and examples must be same size'
@@ -1,3 +1,3 @@
1
1
  module Liblinear
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liblinear-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kei Tsuchiya
@@ -51,7 +51,6 @@ files:
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
- - ext/Makefile
55
54
  - ext/blas.h
56
55
  - ext/blasp.h
57
56
  - ext/daxpy.c
@@ -1,237 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- Q1 = $(V:1=)
7
- Q = $(Q1:0=@)
8
- ECHO1 = $(V:1=@:)
9
- ECHO = $(ECHO1:0=@echo)
10
-
11
- #### Start of system configuration section. ####
12
-
13
- srcdir = .
14
- topdir = $(includedir)/$(RUBY_VERSION_NAME)
15
- hdrdir = $(includedir)/$(RUBY_VERSION_NAME)
16
- arch_hdrdir = $(rubyhdrdir)/$(arch)
17
- PATH_SEPARATOR = :
18
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
- prefix = $(DESTDIR)/home/kei/.rbenv/versions/2.0.0-p195
20
- rubysitearchprefix = $(rubylibprefix)/$(sitearch)
21
- rubyarchprefix = $(rubylibprefix)/$(arch)
22
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
23
- exec_prefix = $(prefix)
24
- vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
25
- sitearchhdrdir = $(sitehdrdir)/$(sitearch)
26
- rubyarchhdrdir = $(rubyhdrdir)/$(arch)
27
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
28
- sitehdrdir = $(rubyhdrdir)/site_ruby
29
- rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
30
- vendorarchdir = $(vendorlibdir)/$(sitearch)
31
- vendorlibdir = $(vendordir)/$(ruby_version)
32
- vendordir = $(rubylibprefix)/vendor_ruby
33
- sitearchdir = $(sitelibdir)/$(sitearch)
34
- sitelibdir = $(sitedir)/$(ruby_version)
35
- sitedir = $(rubylibprefix)/site_ruby
36
- rubyarchdir = $(rubylibdir)/$(arch)
37
- rubylibdir = $(rubylibprefix)/$(ruby_version)
38
- sitearchincludedir = $(includedir)/$(sitearch)
39
- archincludedir = $(includedir)/$(arch)
40
- sitearchlibdir = $(libdir)/$(sitearch)
41
- archlibdir = $(libdir)/$(arch)
42
- ridir = $(datarootdir)/$(RI_BASE_NAME)
43
- mandir = $(datarootdir)/man
44
- localedir = $(datarootdir)/locale
45
- libdir = $(exec_prefix)/lib
46
- psdir = $(docdir)
47
- pdfdir = $(docdir)
48
- dvidir = $(docdir)
49
- htmldir = $(docdir)
50
- infodir = $(datarootdir)/info
51
- docdir = $(datarootdir)/doc/$(PACKAGE)
52
- oldincludedir = $(DESTDIR)/usr/include
53
- includedir = $(prefix)/include
54
- localstatedir = $(prefix)/var
55
- sharedstatedir = $(prefix)/com
56
- sysconfdir = $(prefix)/etc
57
- datadir = $(datarootdir)
58
- datarootdir = $(prefix)/share
59
- libexecdir = $(exec_prefix)/libexec
60
- sbindir = $(exec_prefix)/sbin
61
- bindir = $(exec_prefix)/bin
62
- archdir = $(rubyarchdir)
63
-
64
-
65
- CC = gcc
66
- CXX = g++
67
- LIBRUBY = $(LIBRUBY_A)
68
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
69
- LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir)
70
- LIBRUBYARG_STATIC = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
71
- empty =
72
- OUTFLAG = -o $(empty)
73
- COUTFLAG = -o $(empty)
74
-
75
- RUBY_EXTCONF_H =
76
- cflags = $(optflags) $(debugflags) $(warnflags)
77
- optflags = -O3 -fno-fast-math
78
- debugflags = -ggdb3
79
- warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
80
- CCDLFLAGS = -fPIC
81
- CFLAGS = $(CCDLFLAGS) -Wall -O3 $(ARCH_FLAG)
82
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
83
- DEFS =
84
- CPPFLAGS = -I'/home/kei/.rbenv/versions/2.0.0-p195/include' $(DEFS) $(cppflags)
85
- CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
86
- ldflags = -L. -L'/home/kei/.rbenv/versions/2.0.0-p195/lib' -fstack-protector -rdynamic -Wl,-export-dynamic
87
- dldflags =
88
- ARCH_FLAG =
89
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
90
- LDSHARED = g++ -shared
91
- LDSHAREDXX = $(CXX) -shared
92
- AR = ar
93
- EXEEXT =
94
-
95
- RUBY_INSTALL_NAME = ruby
96
- RUBY_SO_NAME = ruby
97
- RUBYW_INSTALL_NAME =
98
- RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
99
- RUBYW_BASE_NAME = rubyw
100
- RUBY_BASE_NAME = ruby
101
-
102
- arch = x86_64-linux
103
- sitearch = $(arch)
104
- ruby_version = 2.0.0
105
- ruby = $(bindir)/ruby
106
- RUBY = $(ruby)
107
- ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
108
-
109
- RM = rm -f
110
- RM_RF = $(RUBY) -run -e rm -- -rf
111
- RMDIRS = rmdir --ignore-fail-on-non-empty -p
112
- MAKEDIRS = /bin/mkdir -p
113
- INSTALL = /usr/bin/install -c
114
- INSTALL_PROG = $(INSTALL) -m 0755
115
- INSTALL_DATA = $(INSTALL) -m 644
116
- COPY = cp
117
- TOUCH = exit >
118
-
119
- #### End of system configuration section. ####
120
-
121
- preload =
122
-
123
- libpath = . $(libdir)
124
- LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir)
125
- DEFFILE =
126
-
127
- CLEANFILES = mkmf.log
128
- DISTCLEANFILES =
129
- DISTCLEANDIRS =
130
-
131
- extout =
132
- extout_prefix =
133
- target_prefix =
134
- LOCAL_LIBS =
135
- LIBS = -lpthread -lrt -ldl -lcrypt -lm -lc
136
- ORIG_SRCS = dnrm2.c dscal.c daxpy.c ddot.c liblinear_wrap.cxx linear.cpp tron.cpp
137
- SRCS = $(ORIG_SRCS)
138
- OBJS = dnrm2.o dscal.o daxpy.o ddot.o liblinear_wrap.o linear.o tron.o
139
- HDRS = $(srcdir)/linear.h $(srcdir)/blas.h $(srcdir)/blasp.h $(srcdir)/tron.h
140
- TARGET = liblinearswig
141
- TARGET_NAME = liblinearswig
142
- TARGET_ENTRY = Init_$(TARGET_NAME)
143
- DLLIB = $(TARGET).so
144
- EXTSTATIC =
145
- STATIC_LIB =
146
-
147
- BINDIR = $(bindir)
148
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
149
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
150
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
151
- HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
152
- ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
153
-
154
- TARGET_SO = $(DLLIB)
155
- CLEANLIBS = $(TARGET).so
156
- CLEANOBJS = *.o *.bak
157
-
158
- all: $(DLLIB)
159
- static: $(STATIC_LIB)
160
- .PHONY: all install static install-so install-rb
161
- .PHONY: clean clean-so clean-static clean-rb
162
-
163
- clean-static::
164
- clean-rb-default::
165
- clean-rb::
166
- clean-so::
167
- clean: clean-so clean-static clean-rb-default clean-rb
168
- -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
169
-
170
- distclean-rb-default::
171
- distclean-rb::
172
- distclean-so::
173
- distclean-static::
174
- distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
175
- -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
176
- -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
177
- -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
178
-
179
- realclean: distclean
180
- install: install-so install-rb
181
-
182
- install-so: $(DLLIB) ./.RUBYARCHDIR.time
183
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
184
- clean-static::
185
- -$(Q)$(RM) $(STATIC_LIB)
186
- install-rb: pre-install-rb install-rb-default
187
- install-rb-default: pre-install-rb-default
188
- pre-install-rb: Makefile
189
- pre-install-rb-default: Makefile
190
- pre-install-rb-default:
191
- $(ECHO) installing default liblinearswig libraries
192
- ./.RUBYARCHDIR.time:
193
- $(Q) $(MAKEDIRS) $(RUBYARCHDIR)
194
- $(Q) $(TOUCH) $@
195
-
196
- site-install: site-install-so site-install-rb
197
- site-install-so: install-so
198
- site-install-rb: install-rb
199
-
200
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
201
-
202
- .cc.o:
203
- $(ECHO) compiling $(<)
204
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
205
-
206
- .mm.o:
207
- $(ECHO) compiling $(<)
208
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
209
-
210
- .cxx.o:
211
- $(ECHO) compiling $(<)
212
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
213
-
214
- .cpp.o:
215
- $(ECHO) compiling $(<)
216
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
217
-
218
- .C.o:
219
- $(ECHO) compiling $(<)
220
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
221
-
222
- .c.o:
223
- $(ECHO) compiling $(<)
224
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
225
-
226
- .m.o:
227
- $(ECHO) compiling $(<)
228
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
229
-
230
- $(DLLIB): $(OBJS) Makefile
231
- $(ECHO) linking shared-object $(DLLIB)
232
- -$(Q)$(RM) $(@)
233
- $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
234
-
235
-
236
-
237
- $(OBJS): $(HDRS) $(ruby_headers)