Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch logistic classifier to random forest as default classifier #1031

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dedupe/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import tempfile

import numpy
import sklearn.linear_model
import sklearn.ensemble
import sklearn.model_selection

import dedupe.core as core
Expand Down Expand Up @@ -1091,8 +1091,8 @@ def __init__(
]
]
self.classifier = sklearn.model_selection.GridSearchCV(
estimator=sklearn.linear_model.LogisticRegression(),
param_grid={"C": [0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10]},
estimator=sklearn.ensemble.RandomForestClassifier(),
param_grid={"n_estimators": [100, 200, 400, 800]},
scoring="f1",
n_jobs=-1,
)
Expand Down
10 changes: 5 additions & 5 deletions dedupe/labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy
from typing import List
from typing_extensions import Protocol
import sklearn.linear_model
import sklearn.ensemble

import dedupe.core as core
import dedupe.training as training
Expand Down Expand Up @@ -38,7 +38,7 @@ class HasDataModel(Protocol):
data_model: datamodel.DataModel


class RLRLearner(sklearn.linear_model.LogisticRegression, ActiveLearner):
class RFLearner(sklearn.ensemble.RandomForestClassifier, ActiveLearner):
def __init__(self, data_model):
super().__init__()
self.data_model = data_model
Expand Down Expand Up @@ -304,7 +304,7 @@ def _sample(self, data_1, data_2, sample_size):

class DisagreementLearner(ActiveLearner):

classifier: RLRLearner
classifier: RFLearner
blocker: BlockLearner
candidates: List[TrainingExample]

Expand Down Expand Up @@ -409,7 +409,7 @@ def __init__(

self.candidates = self.blocker.candidates

self.classifier = RLRLearner(self.data_model)
self.classifier = RFLearner(self.data_model)
self.classifier.candidates = self.candidates

self._common_init()
Expand Down Expand Up @@ -441,7 +441,7 @@ def __init__(
self.blocker = RecordLinkBlockLearner(data_model, data_1, data_2, index_include)
self.candidates = self.blocker.candidates

self.classifier = RLRLearner(self.data_model)
self.classifier = RFLearner(self.data_model)
self.classifier.candidates = self.candidates

self._common_init()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUp(self):
def test_AL(self):
random.seed(1111111111110)
original_N = len(SAMPLE)
active_learner = dedupe.labeler.RLRLearner(self.data_model)
active_learner = dedupe.labeler.RFLearner(self.data_model)
active_learner.candidates = SAMPLE
assert len(active_learner) == original_N

Expand Down