Bayesian Knowledge Tracing

probabilistic model

  1. pL – latent (mastery)

  2. pT – transition (learning)

  3. pG – guess

  4. pS – slip

  5. Learning order (K)

  6. Problem difficulty

  7. Prior knowledge (initial assessment + sequential)

  8. *Learning rate/speed (derivatives / ODE or PDE)

Equation(a):p(L1)uk=p(L0)kEquation (a): {\displaystyle p(L_{1})_{u}^{k}=p(L_{0})^{k}}
#@title Initialize Parameters

import numpy as np

def initialize_parameters(pL, pT, pS, pG):
  
  np.random.seed(1)

  pL =  np.random.randn(1)
  pT =  np.random.randn(1)
  pS =  np.random.randn(1)
  pG =  np.random.randn(1)

  parameters = {
      'pL': pL,
      'pT': pT,
      'pS': pS,
      'pG': pG
  }

  return parameters
Equation(b):p(Ltobs=correct)uk=p(Lt)uk(1p(S)k)p(Lt)uk(1p(S)k)+(1p(Lt)uk)p(G)kEquation (b): {\displaystyle p(L_{t}|obs=correct)_{u}^{k}={\frac {p(L_{t})_{u}^{k}\cdot (1-p(S)^{k})}{p(L_{t})_{u}^{k}\cdot (1-p(S)^{k})+(1-p(L_{t})_{u}^{k})\cdot p(G)^{k}}}}
#@title Eq. b

# Two state (0 or 1)
# 0 when pL < 0.5; 1 when pL >= 0.5

def correct_latent(pL, pS, pG, T):

  parameters = {}

  for t in range(T-1):
    parameters['pL_correct_obs' + str(t)] = np.dot(pL, (1 - pS))/(np.dot(pL, (1 - pS)) + np.dot((1 - pL), pG))

  return 'pL_correct_obs' + str(t)
Equation(c):p(Ltobs=wrong)uk=p(Lt)ukp(S)kp(Lt)ukp(S)k+(1p(Lt)uk)(1p(G)k)Equation (c): {\displaystyle p(L_{t}|obs=wrong)_{u}^{k}={\frac {p(L_{t})_{u}^{k}\cdot p(S)^{k}}{p(L_{t})_{u}^{k}\cdot p(S)^{k}+(1-p(L_{t})_{u}^{k})\cdot (1-p(G)^{k})}}}
#@title Eq. c

# Two state (0 or 1)
# 0 when pL < 0.5; 1 when pL >= 0.5

def wrong_latent(pL, pS, pG, T):

  parameters = {}

  for t in range(T-1):
    parameters['pL_wrong_obs' + str(t)] = np.dot(pL, pS)/(np.dot(pL, pS) + np.dot((1 - pL), (1 - pG)))

  return 'pL_wrong_obs' + str(t)
Equation(d):p(Lt+1)uk=p(Ltobs)uk+(1p(Ltobs)uk)p(T)kEquation (d): {\displaystyle p(L_{t+1})_{u}^{k}=p(L_{t}|obs)_{u}^{k}+(1-p(L_{t}|obs)_{u}^{k})\cdot p(T)^{k}}
#@title Eq. d

def update_latent(pL_obs, pT, T, condition):

  parameters = {}

  if condition == 'correct':  
    for t in range(T-1):
      pL = 'pL_correct_obs' + str(t)
      parameters['pL' + str(t + 1)] = pL + np.multiply((1 - pL), pT)

  elif condition == 'wrong':  
    for t in range(T-1):
      pL = 'pL_wrong_obs' + str(t)
      parameters['pL' + str(t + 1)] = pL + np.multiply((1 - pL), pT)
  
  return 'pL' + str(t + 1)
Equation(e):p(Ct+1)uk=p(Lt+1)uk(1p(S)k)+(1p(Lt+1)uk)p(G)kEquation (e): {\displaystyle p(C_{t+1})_{u}^{k}=p(L_{t+1})_{u}^{k}\cdot (1-p(S)^{k})+(1-p(L_{t+1})_{u}^{k})\cdot p(G)^{k}}
#@title Eq. e

def observation(pL, pS, pG, T):

  parameters = {}

  for t in range(T-1):
    parameters['pC' + str(t + 1)] = np.dot(pL, (1 - pS)) + np.dot((1 - pL), pG)

  return 'pC' + str(t + 1)

Last updated

Was this helpful?