module 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.
Classes#
class |
truncated documentation |
---|---|
Extends class |
Methods#
method |
truncated documentation |
---|---|
Stores data in the class itself. |
|
Processes images through the model and fits a k-nn. |
|
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.
- 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.- Parameters:
fct – function f applied before looking for neighbors, it can also be a machine learned model
fct_params – parameters sent to function
model_featurizer
pknn – list of parameters, see sklearn.neighborsNearestNeighbors
- _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
- fit(iter_images, n=None, fLOG=None)#
Processes images through the model and fits a k-nn.
- Parameters:
iter_images – Iterator
n – takes n images (or
len(iter_images)
)fLOG – logging function
kwimg – parameters used to preprocess the images
- 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 –
- 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.