Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Recommenders team Recommenders GeoIMC Predict

From Leeroopedia


Knowledge Sources
Domains Matrix Completion, Inference, Recommendation
Last Updated 2026-02-10 00:00 GMT

Overview

The Inferer and PlainScalarProduct classes provide inference and prediction functionality for the GeoIMC model, computing similarity scores from learned parameters and applying optional transformations to produce final recommendations.

Description

The PlainScalarProduct class implements the dot product similarity computation as X dot Y^T for given feature matrices. The Inferer class orchestrates the full prediction pipeline: it transforms entity features using the learned U, B, V matrices by computing X * U * sqrt(B) and Z * V * sqrt(B) via scipy's sqrtm (matrix square root), then computes dot-product similarity scores through the configured method. The Inferer supports three output transformations: mean (binarize predictions using the mean of the inferred matrix as threshold, via the binarize utility), topk (select the top-K items per row and assign them 1 while setting the rest to 0), or empty string (return raw similarity scores without transformation). The method dispatch uses _get_method to resolve the similarity class from a string identifier.

Usage

Use the Inferer class after training a GeoIMC model (via IMCProblem) to generate predictions on new or held-out data. Choose the transformation parameter based on the evaluation scenario: use topk for ranking-based evaluation, mean for threshold-based binary recommendations, or leave empty for raw score output suitable for rating prediction metrics.

Code Reference

Source Location

Signature

class PlainScalarProduct(object):
    def __init__(self, X, Y, **kwargs)
    def sim(self, **kwargs)

class Inferer:
    def __init__(self, method="dot", k=10, transformation="")
    def _get_method(self, k)
    def infer(self, dataPtr, W, **kwargs)

Import

from recommenders.models.geoimc.geoimc_predict import Inferer, PlainScalarProduct

I/O Contract

Inputs

Name Type Required Description
method str No Inference method; currently only "dot" (dot product) is supported (default "dot")
k int No Number of top items for "topk" transformation (default 10)
transformation str No Output transformation: "mean", "topk", or "" for no transformation (default "")
dataPtr (infer) DataPtr or list Yes Data object with X, Z features, or a list of two pre-transformed matrices
W (infer) list Yes List of [U, B, V] learned parameter matrices from IMCProblem
X (PlainScalarProduct) numpy.ndarray Yes User feature matrix of shape (users, features)
Y (PlainScalarProduct) numpy.ndarray Yes Item feature matrix of shape (items, features)

Outputs

Name Type Description
infer return numpy.ndarray Prediction matrix; raw scores, binarized by mean, or binarized by top-k depending on transformation
sim return numpy.ndarray Raw dot-product similarity matrix of shape (users, items)

Usage Examples

Basic Usage

from recommenders.models.geoimc.geoimc_predict import Inferer

# Create an inferer with top-k transformation
inferer = Inferer(method="dot", k=10, transformation="topk")

# Generate predictions using trained model parameters
# W = [U, B, V] from IMCProblem.W
predictions = inferer.infer(dataPtr=test_data, W=imc.W)

# Or use raw scores for rating evaluation
inferer_raw = Inferer(method="dot", transformation="")
raw_scores = inferer_raw.infer(dataPtr=test_data, W=imc.W)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment