from singledispatch import singledispatch


@singledispatch
def explain_prediction(estimator, doc, **kwargs):
    """ Return an explanation of an estimator """
    return {
        "estimator": repr(estimator),
        "description": "Error: estimator %r is not supported" % estimator,
    }


@singledispatch
def explain_weights(estimator, **kwargs):
    """ Return an explanation of an estimator """
    return {
        "estimator": repr(estimator),
        "description": "Error: estimator %r is not supported" % estimator,
    }

from singledispatch import singledispatch

from eli5.base import Explanation


@singledispatch
def explain_prediction(estimator, doc, **kwargs):
    """ Return an explanation of an estimator prediction """
    return Explanation(
        estimator=repr(estimator),
        error="estimator %r is not supported" % estimator,
    )


@singledispatch
def explain_weights(estimator, **kwargs):
    """ Return an explanation of an estimator weights """
    return Explanation(
        estimator=repr(estimator),
        error="estimator %r is not supported" % estimator,
    )

Fix return values of placeholder functions
Fix return values of placeholder functions

This allows to get nicer type completions in the IDE.

  from singledispatch import singledispatch
+ 
+ from eli5.base import Explanation
  
  
  @singledispatch
  def explain_prediction(estimator, doc, **kwargs):
-     """ Return an explanation of an estimator """
+     """ Return an explanation of an estimator prediction """
-     return {
+     return Explanation(
-         "estimator": repr(estimator),
+         estimator=repr(estimator),
-         "description": "Error: estimator %r is not supported" % estimator,
+         error="estimator %r is not supported" % estimator,
-     }
+     )
  
  
  @singledispatch
  def explain_weights(estimator, **kwargs):
-     """ Return an explanation of an estimator """
+     """ Return an explanation of an estimator weights """
-     return {
+     return Explanation(
-         "estimator": repr(estimator),
+         estimator=repr(estimator),
-         "description": "Error: estimator %r is not supported" % estimator,
+         error="estimator %r is not supported" % estimator,
-     }
+     )
  
Fix return values of placeholder functions
## Code Before:
from singledispatch import singledispatch


@singledispatch
def explain_prediction(estimator, doc, **kwargs):
    """ Return an explanation of an estimator """
    return {
        "estimator": repr(estimator),
        "description": "Error: estimator %r is not supported" % estimator,
    }


@singledispatch
def explain_weights(estimator, **kwargs):
    """ Return an explanation of an estimator """
    return {
        "estimator": repr(estimator),
        "description": "Error: estimator %r is not supported" % estimator,
    }

## Instruction:
Fix return values of placeholder functions
## Code After:
from singledispatch import singledispatch

from eli5.base import Explanation


@singledispatch
def explain_prediction(estimator, doc, **kwargs):
    """ Return an explanation of an estimator prediction """
    return Explanation(
        estimator=repr(estimator),
        error="estimator %r is not supported" % estimator,
    )


@singledispatch
def explain_weights(estimator, **kwargs):
    """ Return an explanation of an estimator weights """
    return Explanation(
        estimator=repr(estimator),
        error="estimator %r is not supported" % estimator,
    )
