def partial_fittable_instance(obj, name=None, **kwargs):
    """Asserts that obj has a partial_fit, and instantiates it with **kwargs if obj is given as a type"""
    if name is None:
        if isinstance(obj, type):
            name = obj.__name__
        else:
            name = type(obj).__name__

    assert hasattr(obj, 'partial_fit'), f"{name} doesn't have a partial_fit: {obj} "
    if isinstance(obj, type):
        obj = obj(**kwargs)
    return obj