zepid.superlearner.estimators.EmpiricalMeanSL

class zepid.superlearner.estimators.EmpiricalMeanSL

Empirical mean estimator in the format of SciKit learn. This estimator is for use with the SuperLearner functionality.

Note

Generally, I do not recommend its use outside of SuperLearner. Essentially the empirical mean is a baseline estimator with which to compare other estimators included in SuperLearner.

Parameters:None

Examples

Setup the environment and data set

>>> from zepid import load_sample_data
>>> from zepid.superlearner import EmpiricalMeanSL
>>> df = load_sample_data(False).dropna()
>>> X = np.asarray(df[['art', 'male', 'age0']])
>>> y = np.asarray(df['dead'])

EmpiricalMean estimation

>>> emp_mean = EmpiricalMeanSL()
>>> emp_mean.fit(X=X, y=y)

EmpiricalMean prediction

>>> emp_mean.predict(X=X)

Methods

fit(X, y) Estimate the empirical mean based on X and y.
predict(X) Predict the value of y given a set of X covariates.
fit(X, y)

Estimate the empirical mean based on X and y. While X in input, it has no effect on the estimated empirical mean (since the empirical mean is the average for the full y).

Parameters:
  • X (numpy.array) – Training data
  • y (numpy.array) – Target values
Returns:

Return type:

None

predict(X)

Predict the value of y given a set of X covariates. Because X has no effect on the empirical mean, the mean from the data used in the fit() step is returned for all observations.

Parameters:X (numpy.array) – NumPy array of covariates
Returns:
Return type:NumPy array of predicted empirical means of the dimension X.shape[0]