/** * Bayesian Knowledge Tracing (BKT) * * Implements the classic BKT model for tracking learner mastery. * BKT is a hidden Markov model with two hidden states (mastery/no mastery) * and uses four parameters: * - P(L₀): Prior probability of mastery (pInit) * - P(T): Probability of learning/transition (pLearn) * - P(S): Probability of slip (wrong despite mastery) (pSlip) * - P(G): Probability of guess (correct despite no mastery) (pGuess) * * @see Corbett & Anderson (1994). Knowledge tracing: Modeling the acquisition * of procedural knowledge. User Modeling and User-Adapted Interaction. * * @packageDocumentation */ import type { SkillId } from '../types/skill.js'; import type { BKTParameters, BKTState, BKTConfig, MasteryState } from '../types/index.js'; /** * Default BKT configuration */ export declare const BKT_CONFIG_DEFAULTS: Required; /** * BKT update result */ export interface BKTUpdateResult { /** Updated mastery probability */ pMastery: number; /** Whether mastery threshold is met */ isMastered: boolean; /** Probability of the observation given the model */ likelihood: number; /** Previous mastery probability (before update) */ previousMastery: number; } /** * BKT prediction result */ export interface BKTPrediction { /** Probability of correct response */ pCorrect: number; /** Expected mastery after correct response */ masteryIfCorrect: number; /** Expected mastery after incorrect response */ masteryIfIncorrect: number; } /** * Bayesian Knowledge Tracing Engine * * Tracks learner mastery using the classic BKT model. * Can be used with skill-level or global parameters. * * @example * ```typescript * const bkt = new BKTEngine(); * * // Initialize state for a skill * let state = bkt.initializeState('skill-1'); * * // Update after correct response * state = bkt.update(state, true).state; * console.log(`Mastery: ${state.pMastery.toFixed(2)}`); * * // Update after incorrect response * state = bkt.update(state, false).state; * ``` */ export declare class BKTEngine { private readonly config; private readonly skillParams; private readonly globalParams; constructor(config?: BKTConfig, globalParams?: BKTParameters); /** * Set parameters for a specific skill */ setSkillParameters(skillId: SkillId, params: BKTParameters): void; /** * Get parameters for a skill (falls back to global) */ getParameters(skillId?: SkillId): BKTParameters; /** * Initialize BKT state for a skill */ initializeState(skillId: SkillId): BKTState; /** * Update BKT state based on an observed response * * Uses Bayes' theorem to update the mastery probability: * - For correct response: P(Lₙ|correct) ∝ P(correct|Lₙ) × P(Lₙ) * - For incorrect response: P(Lₙ|incorrect) ∝ P(incorrect|Lₙ) × P(Lₙ) * * Then applies the learning transition. * * @param state - Current BKT state * @param correct - Whether the response was correct * @param skillId - Optional skill ID for skill-specific parameters * @returns Updated state and result information */ update(state: BKTState, correct: boolean, skillId?: SkillId): { state: BKTState; result: BKTUpdateResult; }; /** * Update from multiple responses */ updateBatch(state: BKTState, responses: boolean[], skillId?: SkillId): { state: BKTState; results: BKTUpdateResult[]; }; /** * Predict the probability of a correct response */ predict(state: BKTState, skillId?: SkillId): BKTPrediction; /** * Estimate number of opportunities until mastery * * Uses a forward simulation assuming consistent correct responses. */ estimateOpportunitiesToMastery(state: BKTState, skillId?: SkillId, maxOpportunities?: number): number | null; /** * Check if mastery threshold is met */ isMastered(state: BKTState): boolean; /** * Convert BKT state to MasteryState for integration with other systems */ toMasteryState(state: BKTState): Partial; /** * Calculate current streak from history */ private calculateStreak; } /** * Parameter fitting for BKT using grid search * * Finds optimal BKT parameters for a set of response sequences. * Uses grid search with log-likelihood as the objective. */ export interface BKTFitResult { /** Best parameters found */ params: BKTParameters; /** Log-likelihood of the data given the parameters */ logLikelihood: number; /** Number of parameter combinations evaluated */ evaluations: number; } /** * Fit BKT parameters to response data * * @param sequences - Array of response sequences (true = correct) * @param gridSize - Number of values to try for each parameter * @returns Best fitting parameters * * @example * ```typescript * const sequences = [ * [false, false, true, true, true], * [true, false, true, true, true], * [false, true, true, true, true], * ]; * * const result = fitBKTParameters(sequences); * console.log('Best parameters:', result.params); * ``` */ export declare function fitBKTParameters(sequences: boolean[][], gridSize?: number): BKTFitResult; /** * Calculate log-likelihood of response sequences given BKT parameters */ export declare function calculateLogLikelihood(sequences: boolean[][], params: BKTParameters): number; /** * Create a BKT engine with default configuration */ export declare function createBKTEngine(config?: BKTConfig, params?: BKTParameters): BKTEngine; /** * Quick mastery estimation using BKT * * Convenience function for simple use cases. * * @param responses - Sequence of correct/incorrect responses * @param params - BKT parameters (optional, uses defaults) * @returns Final mastery probability */ export declare function estimateMastery(responses: boolean[], params?: BKTParameters): number; //# sourceMappingURL=bkt.d.ts.map