initialize the disagreement labeler with some positive examples
@@ -107,6 +107,7 @@ class RLRLearner(ActiveLearner, rlr.RegularizedLogisticRegression):
return self.data_model.distances(pairs)
def fit(self, X, y):
+
self.y = numpy.array(y)
self.X = X
@@ -245,9 +246,9 @@ class DedupeBlockLearner(BlockLearner):
sampled_records,
index_data)
- examples_to_index = candidates
+ examples_to_index = candidates.copy()
if index_include:
- candidates += index_include
+ examples_to_index += index_include
self._index_predicates(examples_to_index)
@@ -289,9 +290,9 @@ class RecordLinkBlockLearner(BlockLearner):
sampled_records_2,
index_data)
- examples_to_index = candidates
+ examples_to_index = candidates.copy()
if index_include:
- candidates += index_include
+ examples_to_index += index_include
self._index_predicates(examples_to_index)
@@ -337,7 +338,8 @@ class DisagreementLearner(ActiveLearner):
if disagreement.any():
conflicts = disagreement.nonzero()[0]
- uncertain_index = numpy.random.choice(conflicts, 1)[0]
+ target = numpy.random.uniform(size=1)
+ uncertain_index = conflicts[numpy.argmax(probs[conflicts][:, 0] - target)]
else:
uncertain_index = numpy.std(probs, axis=1).argmax()
@@ -404,6 +406,12 @@ class DedupeDisagreementLearner(DisagreementLearner, DedupeSampler):
self.candidates = super().sample(data, blocked_proportion, sample_size)
+ random_pair = random.choice(self.candidates)
+ exact_match = (random_pair[0], random_pair[0])
+
+ index_include = index_include.copy()
+ index_include.append(exact_match)
+
self.blocker = DedupeBlockLearner(data_model,
self.candidates,
data,
@@ -412,6 +420,9 @@ class DedupeDisagreementLearner(DisagreementLearner, DedupeSampler):
self._common_init()
+ self.mark([exact_match] * 4 + [random_pair],
+ [1] * 4 + [0])
+
class RecordLinkDisagreementLearner(DisagreementLearner, RecordLinkSampler):
@@ -437,6 +448,12 @@ class RecordLinkDisagreementLearner(DisagreementLearner, RecordLinkSampler):
blocked_proportion,
sample_size)
+ random_pair = random.choice(self.candidates)
+ exact_match = (random_pair[0], random_pair[0])
+
+ index_include = index_include.copy()
+ index_include.append(exact_match)
+
self.blocker = RecordLinkBlockLearner(data_model,
self.candidates,
data_1,
@@ -447,6 +464,9 @@ class RecordLinkDisagreementLearner(DisagreementLearner, RecordLinkSampler):
self._common_init()
+ self.mark([exact_match] * 4 + [random_pair],
+ [1] * 4 + [0])
+
class Sample(dict):
