Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BUG] Underflows in LabelPropagation and LabelSpreading should be ignored. #9313

Copy link
Copy link
Closed
@musically-ut

Description

@musically-ut
Issue body actions

Description

LabelPropagation with the rbf kernel should ignore underflow errors.

Steps/Code to Reproduce

Example taken from #9292.

from sklearn.datasets import fetch_mldata
from sklearn.semi_supervised import label_propagation
import numpy

numpy.seterr(all='raise')

mnist = fetch_mldata('MNIST original', data_home="./tmp")

X = mnist.data[1:10000]
y = mnist.target[1:10000]

# Use only 300 labeled examples
y[300:] = -1

lp_model = label_propagation.LabelSpreading(kernel='rbf', n_neighbors=7, n_jobs=-1)
lp_model.fit(X,y)

Expected Results

No error should be thrown.

Actual Results

Traceback (most recent call last):
  File "reproduce.py", line 21, in <module>
    lp_model.fit(X,y)
  File "/share/mug/gentoo/anaconda3/envs/ssl-py3/lib/python3.6/site-packages/sklearn/semi_supervised/label_propagation.py", line 234, in fit
    graph_matrix = self._build_graph()
  File "/share/mug/gentoo/anaconda3/envs/ssl-py3/lib/python3.6/site-packages/sklearn/semi_supervised/label_propagation.py", line 511, in _build_graph
    affinity_matrix = self._get_kernel(self.X_)
  File "/share/mug/gentoo/anaconda3/envs/ssl-py3/lib/python3.6/site-packages/sklearn/semi_supervised/label_propagation.py", line 131, in _get_kernel
    return rbf_kernel(X, X, gamma=self.gamma)
  File "/share/mug/gentoo/anaconda3/envs/ssl-py3/lib/python3.6/site-packages/sklearn/metrics/pairwise.py", line 837, in rbf_kernel
    np.exp(K, K)    # exponentiate K in-place
FloatingPointError: underflow encountered in exp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.