adapt.metrics.make_uda_scorer

adapt.metrics.make_uda_scorer(func, Xs, Xt, greater_is_better=False, **kwargs)[source]

Make a scorer function from an adapt metric.

The goal of adapt metric is to measure the closeness between a source input dataset Xs and a target input dataset Xt. If Xs is close from Xt, it can be expected that a good model trained on source will perform well on target.

The returned score function will apply func on a transformation of Xs and Xt given to make_uda_scorer.

If the estimator given in the score function is a feature-based method, the metric will be applied on the encoded Xs and Xt. If the estimator is instead an instance-based method, a weighted bootstrap sample of Xs will be compared to Xt.

IMPORTANT NOTE : when the returned score function is used with GridSearchCV from sklearn, the parameter return_train_score must be set to True. The adapt score then corresponds to the train scores.

Parameters
funccallable

Adapt metric with signature func(Xs, Xt, **kwargs).

Xsarray

Source input dataset

Xtarray

Target input dataset

greater_is_betterbool, default=True

Whether the best outputs of func are the greatest ot the lowest. For all adapt metrics, the low values mean closeness between Xs and Xt.

kwargskey, value arguments

Parameters given to func.

Returns
scorercallable

A scorer function with signature scorer(estimator, X, y_true=None). The scorer function transform the parameters Xs and Xt with the given estimator. Then it rerurns func(Xst, Xtt) with Xst and Xtt the transformed data.

Notes

When the returned score function is used with GridSearchCV from sklearn, the parameter return_train_score must be set to True. The adapt score then corresponds to the train scores.