Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Ruby binding #38

Merged
merged 4 commits into from
Jan 24, 2016
Merged

Conversation

abicky
Copy link
Contributor

@abicky abicky commented Apr 11, 2015

I have implemented Ruby binding and have confirmed that it works as expected on Mac OS X 10.10.2 with Swig 3.0.5, Debian 6.0.5 with Swig 3.0.5, and Debian 6.0.5 with Swig 2.0.4.

Installation

$ cd swig/ruby
$ ./prepare.sh --swig
$ ruby extconf.rb
$ make install 

Execute sample codes

$ cd swig/ruby
$ curl -LO http://www.cnts.ua.ac.be/conll2000/chunking/train.txt.gz
$ zcat train.txt.gz | ../../example/chunking.py > train.crfsuite.txt
$ ruby sample_train.rb CoNLL2000.model < train.crfsuite.txt
0.12.2
feature.minfreq 0.000000 The minimum frequency of features.
feature.possible_states 0 Force to generate possible state features.
feature.possible_transitions 0 Force to generate possible transition features.
c2 1.000000 Coefficient for L2 regularization.
max_iterations 1000 The maximum number of iterations (epochs) for SGD optimization.
period 10 The duration of iterations to test the stopping criterion.
delta 0.000001 The threshold for the stopping criterion; an optimization process stops when
the improvement of the log likelihood over the last ${period} iterations is no
greater than this threshold.
calibration.eta 0.100000 The initial value of learning rate (eta) used for calibration.
calibration.rate 2.000000 The rate of increase/decrease of learning rate for calibration.
calibration.samples 1000 The number of instances used for calibration.
calibration.candidates 10 The number of candidates of learning rate.
calibration.max_trials 20 The maximum number of trials of learning rates for calibration.
Feature generation
type: CRF1d
feature.minfreq: 0.000000
feature.possible_states: 0
feature.possible_transitions: 0
0....1....2....3....4....5....6....7....8....9....10
Number of features: 452755
Seconds required: 2.648

Stochastic Gradient Descent (SGD)
c2: 0.100000
max_iterations: 1000
period: 10
delta: 0.000001

Calibrating the learning rate (eta)
calibration.eta: 0.100000
calibration.rate: 2.000000
calibration.samples: 1000
calibration.candidates: 10
calibration.max_trials: 20
Initial loss: 73427.713480
Trial #1 (eta = 0.100000): 6582.519447
Trial #2 (eta = 0.200000): 6730.455920
Trial #3 (eta = 0.400000): 9512.830812
Trial #4 (eta = 0.800000): 18893.911403
Trial #5 (eta = 1.600000): 37728.232850
Trial #6 (eta = 3.200000): 80183.389088 (worse)
Trial #7 (eta = 0.050000): 7630.312307
Trial #8 (eta = 0.025000): 9621.753885
Trial #9 (eta = 0.012500): 12638.018534
Trial #10 (eta = 0.006250): 16982.966482
Trial #11 (eta = 0.003125): 23074.675027
Trial #12 (eta = 0.001563): 31343.061039
Trial #13 (eta = 0.000781): 41540.646706
Trial #14 (eta = 0.000391): 52696.836433
Trial #15 (eta = 0.000195): 61945.207748
Trial #16 (eta = 0.000098): 67498.204541
Best learning rate (eta): 0.100000
Seconds required: 2.078

***** Epoch #1 *****
Loss: 33583.103783
Feature L2-norm: 63.611729
Learning rate (eta): 0.098039
Total number of feature updates: 8936
Seconds required for this iteration: 1.046

(snip)

SGD terminated with the stopping criteria
Loss: 3523.303519
Total seconds required for training: 164.998

Storing the model
Number of active features: 452755 (452755)
Number of active attributes: 335674 (335674)
Number of active labels: 22 (22)
Writing labels
Writing attributes
Writing feature references for transitions
Writing feature references for attributes
Seconds required: 1.120

$ ruby sample_tag.rb CoNLL2000.model < train.crfsuite.txt > result

chokkan pushed a commit that referenced this pull request Jan 24, 2016
@chokkan chokkan merged commit d16d095 into chokkan:master Jan 24, 2016
@abicky abicky deleted the feature/ruby-binding branch October 3, 2016 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants