Skip to content

Commit

Permalink
add abstract strategy and random strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
nnnyt committed Jan 19, 2021
1 parent ec2f5d7 commit a3e1b2a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CAT/strategy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .abstract_strategy import AbstractStrategy
from .random_strategy import RandomStrategy
24 changes: 24 additions & 0 deletions CAT/strategy/abstract_strategy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from abc import ABC, abstractmethod


class AbstractStrategy(ABC):

@property
@abstractmethod
def name(self):
""" the name of the strategy
Returns:
name: str
"""
raise NotImplementedError

@abstractmethod
def adaptest_select(self, model, adaptest_data):
"""
Args:
model: AbstractModel
adaptest_data: AdapTestDataset
Returns:
selected_questions: dict, {student_idx: question_idx}
"""
raise NotImplementedError
21 changes: 21 additions & 0 deletions CAT/strategy/random_strategy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np
from .abstract_strategy import AbstractStrategy
from ..model import AbstractModel
from ..dataset import AdapTestDataset


class RandomStrategy(AbstractStrategy):

def __init__(self):
super().__init__()

@property
def name(self):
return 'Random Select Strategy'

def adaptest_select(self, model: AbstractModel, adaptest_data: AdapTestDataset):
selection = {}
for sid in range(adaptest_data.num_students):
untested_questions = np.array(list(adaptest_data.untested[sid]))
selection[sid] = np.random.randint(len(untested_questions))
return selection

0 comments on commit a3e1b2a

Please sign in to comment.