module search_rank.search_engine_predictions_images#

Inheritance diagram of mlinsights.search_rank.search_engine_predictions_images

Short summary#

module mlinsights.search_rank.search_engine_predictions_images

Implements a way to get close examples based on the output of a machine learned model.

source on GitHub

Classes#

class

truncated documentation

SearchEnginePredictionImages

Extends class SearchEnginePredictions. Vectors are coming from images. The metadata must contains information …

Methods#

method

truncated documentation

_prepare_fit

Stores data in the class itself.

fit

Processes images through the model and fits a k-nn.

kneighbors

Searches for neighbors close to the first image returned by iter_images. It returns the neighbors only …

Documentation#

Implements a way to get close examples based on the output of a machine learned model.

source on GitHub

class mlinsights.search_rank.search_engine_predictions_images.SearchEnginePredictionImages(fct, fct_params=None, **knn)#

Bases: SearchEnginePredictions

Extends class SearchEnginePredictions. Vectors are coming from images. The metadata must contains information about path names. We assume all images can hold in memory. An example can found in notebook Search images with deep learning (keras) or Search images with deep learning (torch). Another example can be found there: search_images_dogcat.py.

source on GitHub

Parameters:

source on GitHub

_prepare_fit(data=None, features=None, metadata=None, transform=None, n=None, fLOG=None)#

Stores data in the class itself.

Parameters:
  • data – a dataframe or None if the the features and the metadata are specified with an array and a dictionary

  • features – features columns or an array

  • metadata – data

  • transform – transform each vector before using it

  • n – takes n images (or len(iter_images))

  • fLOG – logging function

source on GitHub

fit(iter_images, n=None, fLOG=None)#

Processes images through the model and fits a k-nn.

Parameters:
  • iter_imagesIterator

  • n – takes n images (or len(iter_images))

  • fLOG – logging function

  • kwimg – parameters used to preprocess the images

source on GitHub

kneighbors(iter_images, n_neighbors=None)#

Searches for neighbors close to the first image returned by iter_images. It returns the neighbors only for the first image.

Parameters:

iter_images

Iterator

Returns:

score, ind, meta

score is an array representing the lengths to points, ind contains the indices of the nearest points in the population matrix, meta is the metadata.

source on GitHub