b34a1085165933fcffc6d863c2f7274b87bd2b09,qanta/reranker/svm.py,Reranker,create_train,#Any#Any#Any#,100
Before Change
def create_train(example_generator, questions, guesses):
data = dlib.sparse_ranking_pair()
for row, gg in guesses.iterrows():
guess = gg["guess"]
answer = questions[gg["qnum"]].page
text = questions[gg["qnum"]].get_text(gg["sentence"],
gg["token"])
if guess == answer:
data.relevant.append(example_generator(text, gg[1]))
else:
data.nonrelevant.append(example_generator(text, gg[1]))
return data
def train_svm(data, c_val=10):
trainer = dlib.svm_rank_trainer()
After Change
queries = dlib.sparse_ranking_pairs()
num_examples = 0
for ex in Reranker.row_iterator(example_generator,
questions, guesses):
// Skip bad rows
if ex.vector is None:
continue
if ex.new:
if num_examples > 0 and has_correct:
queries.append(data)
data = dlib.sparse_ranking_pair()
has_correct = False
if ex.is_correct:
has_correct = True
data.relevant.append(ex.vector)
else:
data.nonrelevant.append(ex.vector)
num_examples += 1
queries.append(data)
return queries
def score_one(self, example):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: Pinafore/qb
Commit Name: b34a1085165933fcffc6d863c2f7274b87bd2b09
Time: 2017-06-01
Author: jordanbg@gmail.com
File Name: qanta/reranker/svm.py
Class Name: Reranker
Method Name: create_train
Project Name: CellProfiler/CellProfiler
Commit Name: 01444cc8270b4517efcb2060d2814e025325d5f1
Time: 2010-11-18
Author: leek@1fc53939-2000-0410-845c-e8453a809027
File Name: cellprofiler/gui/metadatactrl.py
Class Name: MetadataControl
Method Name: hit_test
Project Name: CellProfiler/CellProfiler
Commit Name: 1f6d1aa5eb7d4c31960e7b2aba04d94439956a49
Time: 2010-07-06
Author: leek@1fc53939-2000-0410-845c-e8453a809027
File Name: cellprofiler/gui/metadatactrl.py
Class Name: MetadataControl
Method Name: OnPaint