forked from bigdata-ustc/EduCAT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
243 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import numpy as np | ||
|
||
from CAT.strategy.abstract_strategy import AbstractStrategy | ||
from CAT.model import AbstractModel | ||
from CAT.dataset import AdapTestDataset | ||
import random | ||
|
||
class BECATstrategy(AbstractStrategy): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
@property | ||
def name(self): | ||
return 'BECAT Strategy' | ||
def adaptest_select(self, model: AbstractModel, adaptest_data: AdapTestDataset,S_set): | ||
""" | ||
submodular computation | ||
""" | ||
assert hasattr(model, 'delta_q_S_t'), \ | ||
'the models must implement delta_q_S_t method' | ||
assert hasattr(model, 'get_pred'), \ | ||
'the models must implement get_pred method for accelerating' | ||
pred_all = model.get_pred(adaptest_data) | ||
|
||
#reduced_pred_all = {**reduced_pred_all, **selected_questions_sample} | ||
selection = {} | ||
for sid in range(adaptest_data.num_students): | ||
tmplen = (len(S_set[sid])) | ||
untested_questions = np.array(list(adaptest_data.untested[sid])) | ||
sampled_elements = np.random.choice(untested_questions, tmplen + 5) | ||
untested_deltaq = [model.delta_q_S_t(qid, pred_all[sid],S_set[sid],sampled_elements) for qid in untested_questions] | ||
|
||
j = np.argmax(untested_deltaq) | ||
selection[sid] = untested_questions[j] | ||
# Question bank Q | ||
return selection | ||
|
This file contains 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
This file contains 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