Skip to content

Commit

Permalink
add custom parameters max_iter and tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
kholdrex committed Jun 9, 2024
1 parent 22b0d94 commit 30ad9cb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/irt_ruby/rasch_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
module IrtRuby
# A class representing the Rasch model for Item Response Theory.
class RaschModel
def initialize(data)
def initialize(data, max_iter: 1000, tolerance: 1e-6)
@data = data
@abilities = Array.new(data.row_count) { rand }
@difficulties = Array.new(data.column_count) { rand }
@max_iter = 1000
@tolerance = 1e-6
@max_iter = max_iter
@tolerance = tolerance
end

def sigmoid(x)
Expand Down
6 changes: 3 additions & 3 deletions lib/irt_ruby/three_parameter_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
module IrtRuby
# A class representing the Three-Parameter model for Item Response Theory.
class ThreeParameterModel
def initialize(data)
def initialize(data, max_iter: 1000, tolerance: 1e-6)
@data = data
@abilities = Array.new(data.row_count) { rand }
@difficulties = Array.new(data.column_count) { rand }
@discriminations = Array.new(data.column_count) { rand }
@guessings = Array.new(data.column_count) { rand * 0.3 }
@max_iter = 1000
@tolerance = 1e-6
@max_iter = max_iter
@tolerance = tolerance
end

def sigmoid(x)
Expand Down
6 changes: 3 additions & 3 deletions lib/irt_ruby/two_parameter_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
module IrtRuby
# A class representing the Two-Parameter model for Item Response Theory.
class TwoParameterModel
def initialize(data)
def initialize(data, max_iter: 1000, tolerance: 1e-6)
@data = data
@abilities = Array.new(data.row_count) { rand }
@difficulties = Array.new(data.column_count) { rand }
@discriminations = Array.new(data.column_count) { rand }
@max_iter = 1000
@tolerance = 1e-6
@max_iter = max_iter
@tolerance = tolerance
end

def sigmoid(x)
Expand Down
2 changes: 1 addition & 1 deletion spec/irt_ruby/rasch_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe IrtRuby::RaschModel do
let(:data) { Matrix[[1, 0, 1], [0, 1, 0], [1, 1, 1]] }
let(:irt_model) { IrtRuby::RaschModel.new(data) }
let(:irt_model) { IrtRuby::RaschModel.new(data, max_iter: 2000) }

describe "#sigmoid" do
it "calculates the sigmoid of a value" do
Expand Down
2 changes: 1 addition & 1 deletion spec/irt_ruby/three_parameter_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe IrtRuby::ThreeParameterModel do
let(:data) { Matrix[[1, 0, 1], [0, 1, 0], [1, 1, 1]] }
let(:model) { IrtRuby::ThreeParameterModel.new(data) }
let(:model) { IrtRuby::ThreeParameterModel.new(data, max_iter: 1500) }

describe "#initialize" do
it "initializes with data" do
Expand Down
2 changes: 1 addition & 1 deletion spec/irt_ruby/two_parameter_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe IrtRuby::TwoParameterModel do
let(:data) { Matrix[[1, 0, 1], [0, 1, 0], [1, 1, 1]] }
let(:model) { IrtRuby::TwoParameterModel.new(data) }
let(:model) { IrtRuby::TwoParameterModel.new(data, max_iter: 3000) }

describe "#initialize" do
it "initializes with data" do
Expand Down

0 comments on commit 30ad9cb

Please sign in to comment.