expected_target_val#

skactiveml.pool.utils.expected_target_val(X, target_func, reg, **kwargs)[source]#

Calculates the conditional expectation of a function depending only on the target value for each sample in X, i.e., E[target_func(Y)|X=x], where Y | X=x ~ reg.predict_target_distribution, for x in X.

Parameters:
Xarray-like of shape (n_samples, n_features)

The samples where the expectation should be evaluated.

target_funccallable

The function that transforms the random variable.

regProbabilisticRegressor

Predicts the target distribution over which the expectation is calculated.

Returns:
expectationnumpy.ndarray of shape (n_samples,)

The conditional expectation for each value applied.

Other Parameters:
methodstring, optional, optional (default=’gauss_hermite’)

The method by which the expectation is computed.

  • ‘assume_linear’ assumes E[func(Y)|X=x_eval] ~= func(E[Y|X=x_eval]) and thereby only takes the function value at the expected y value.

  • ‘monte_carlo’ Basic monte carlo integration. Taking the average of randomly drawn samples. n_integration_samples specifies the number of monte carlo samples.

  • ‘quantile’ Uses the quantile function to transform the integration space into the interval from 0 to 1 and than uses the method from ‘quantile_method’ to calculate the integral. The number of integration points is specified by n_integration_samples.

  • ‘gauss_hermite’ Uses Gauss-Hermite quadrature. This assumes Y | X to be gaussian distributed. The number of evaluation points is given by n_integration_samples.

  • ‘dynamic_quad’ uses scipy’s function expect on the rv_continuous random variable of reg, which in turn uses a dynamic gaussian quadrature routine for calculating the integral. A random variable with zero standard deviation is evaluated at its mean instead. Performance is worse using a vector function.

quantile_methodstring, default=’quadrature’

Specifies the integration methods used after the quantile transformation.

  • ‘trapezoid’ Trapezoidal method for integration using evenly spaced samples.

  • ‘simpson’ Simpson method for integration using evenly spaced samples.

  • ‘average’ Taking the average value for integration using evenly spaced samples.

  • ‘romberg’ Romberg method for integration. If n_integration_samples is not equal to 2**k + 1 for a natural number k, the number of samples used for integration is put to the smallest such number greater than n_integration_samples.

  • ‘quadrature’ Gaussian quadrature method for integration.

n_integration_samplesint, default=10

The number of integration samples used in ‘quantile’, ‘monte_carlo’ and ‘gauss-hermite’.

quad_dictdict, default=None

Further arguments for using scipy’s expect

random_stateint or np.random.RandomState or None, default=None

Random state for fixing the number generation.

target_funcbool

If True only the target values will be passed to func.

vector_funcbool or str, default=False

If vector_func is True, the integration values are passed as a whole to the function func. If vector_func is ‘both’, the integration values might or might not be passed as a whole. The integration values if passed as a whole are of the form (n_samples, n_integration), where n_integration denotes the number of integration values.