Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • bob.learn.em bob.learn.em
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • bobbob
  • bob.learn.embob.learn.em
  • Issues
  • #3
Closed
Open
Issue created Apr 23, 2015 by André Anjos@andre.anjos💬Owner

KMeans returns NaNs

Created by: siebenkopf

I have lately run into a problem, where the bob.learn.em.KMeansTrainer returns a machine, where some of the means are nan. I have enough training data (several millions), and I want to have 1000 means.

I guess that this problem is related to the fact that some means are under-represented with data (i.e., no data point is assigned for a specific mean). Then, re-computing the means will end up in a division by zero, which turns into nan values. To avoid that, it is possible to re-initialize the under-represented mean by selecting the data point that is furthest away from the (other) current means, something like:

# get the maximum distance
furthest_training_sample = numpy.argmax([max(distance(data, mean) for mean in means) for data in training_data])
# assign new mean
new_mean = training_data[furthest_training_sample]
Edited Feb 11, 2022 by Tiago de Freitas Pereira
Assignee
Assign to
Time tracking