<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def autobinning(data, method="freedman_diaconis"):
 """ This method determines the optimal binning for histogramming. Parameters data: 1D array-like Input data. method: string, one of the following: - sturges - sturges-doane - scott - sqrt - doane - freedman-diaconis - risk - knuth Returns ------- (nbins, min, max):
 int, type(data), type(data) nbins is the optimal number of bin estimated by the method min is the minimum of data max is the maximum of data Notes ----- If the length of data is less than 4 the method retun nbins = 1 """

    name = method.replace("-", "_")
    try:
        method = getattr(BinningMethods, name)
        if not isinstance(method, types.FunctionType):
            raise AttributeError
    except AttributeError:
        raise ValueError("`{0}` is not a valid binning method".format(name))
    if len(data) < 4:
        return 1, np.min(data), np.max(data)
    return int(np.ceil(method(data))), np.min(data), np.max(data)