8000 Ignore underflow in LabelPropagation by warut-vijit · Pull Request #9384 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Ignore underflow in LabelPropagation #9384

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

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions sklearn/semi_supervised/label_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def fit(self, X, y):
self.X_ = X
check_classification_targets(y)

# ignore expected underflow
old_error_settings = np.geterr()
np.seterr(invalid='ignore', under='ignore')

# actual graph construction (implementations should override this)
graph_matrix = self._build_graph()

Expand Down Expand Up @@ -290,6 +294,9 @@ def fit(self, X, y):
normalizer = np.sum(self.label_distributions_, axis=1)[:, np.newaxis]
self.label_distributions_ /= normalizer

# restore error settings
np.seterr(**old_error_settings)

# set the transduction item
transduction = self.classes_[np.argmax(self.label_distributions_,
axis=1)]
Expand Down
0