def model_predictions(featureset, model, return_probs=True):
    """Construct a DataFrame of model predictions for given featureset.

    Parameters
    ----------
    featureset : xarray.Dataset
        Dataset containing feature values for which predictions are desired
    model : scikit-learn model
        Fitted scikit-learn model to be used to generate predictions
    return_probs : bool, optional
        Parameter to control the type of prediction made in the classification
        setting (the parameter has no effect for regression models). If True,
        probabilities for each class are returned where possible; if False,
        only the top predicted label for each time series is returned.

    Returns
    -------
    pandas.DataFrame
        DataFrame of model predictions, indexed by `featureset.name`. Each row
        contains either a single class/target prediction or (for probabilistic
        predictions) a list of class probabilities.
    """
    feature_df = build_model.rectangularize_featureset(featureset)
    if return_probs:
        try:
            preds = model.predict_proba(feature_df)
        except __HOLE__:
            preds = model.predict(feature_df)
    else:
        preds = model.predict(feature_df)

    if len(preds.shape) == 1:
        return pd.Series(preds, index=feature_df.index, name='prediction')
    else:
        if isinstance(model, GridSearchCV):
            columns = model.best_estimator_.classes_
        else:
            columns = model.classes_
        return pd.DataFrame(preds, index=feature_df.index, columns=columns)
dataset/ETHPy150Open cesium-ml/cesium/cesium/predict.py/model_predictions