Repository navigation
feat: add ItemBank for storing and reusing calibrated items - #25
Merged
Merged
Conversation
Fit results are positional arrays tied to one in-memory model, so an app that wants to work with new respondents has to recalibrate or invent its own storage. ItemBank is an immutable, id-keyed set of item parameters with a versioned JSON format, per-model validation, recorded calibration provenance, and response probabilities, so a bank calibrated once (here or in R's mirt) can be loaded anywhere. It is the base for scoring new respondents against fixed items.
Review found that callers could mutate the model name, from_fit invented a = 1 / c = 0 for missing estimates, eql? disagreed with hash, huge integers became Infinity after validation, excluded items skipped id checks, and Rasch slopes near 1 were stored unnormalized. Scoring new respondents will also need the calibration ability distribution, which the format could not carry, so add an optional ability_distribution now rather than bump format_version later. The mirt recipe now writes 17 significant digits and exports the latent mean and variance.
Integer abilities were averaged with integer division, non-finite ones silently dropped the ability distribution, and a non-Array difficulties value raised NoMethodError instead of ArgumentError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fit results are positional arrays tied to one in-memory model. An app that wants to work with new respondents (for example, a Rails assessment app) has to either recalibrate or invent its own storage for item parameters. This is step 2 of the roadmap and the base for the next step: scoring new respondents (EAP/MAP) against fixed items.
What
IrtRuby::ItemBankis an immutable, id-keyed set of calibrated items. It uses the logistic metric without a scaling constant, the same as R'smirt:P = c + (1 - c) / (1 + exp(-a (theta - b))).format: "irt_ruby.item_bank",format_version: 1,model, items{id, a, b, c}, optionalability_distribution: {mean, sd}, and free-formmetadata. Unknown formats and newer versions are rejected.from_fit. Infers the model from the result keys. Records provenance (gem version, scale convention,converged,iterations) and the calibration sample's ability distribution. It never invents values for estimated parameters. Items withnilestimates raise an error unlessexclude_unestimated: trueis passed, in which case they are listed undermetadata["unestimated_items"].==,eql?andhashare consistent.mirt: it usescoef(..., IRTpars = TRUE, simplify = TRUE)andjsonlitewithdigits = I(17)for exact doubles, and exports the latent mean and variance.Verification
spec/irt_ruby/item_bank_spec.rbcovers building from all three models, JSON round-trip and format, validation, immutability, equality and probabilities. A README example spec is also added.mirtis the next roadmap step.