def JSONify_estimator(est,
                      model_selection=False,
                      param_val=None,
                      out=None,
                      path_to_mr=None,
                      mapper="mapper.py",
                      i_red="inner_reducer.py",
                      o_red="outer_reducer.py"):
    if path_to_mr is None:
        import mempamal
        path_to_mr = path.join(path.dirname(mempamal.__file__), "scripts")
    # introspection of the estimator
    steps = []
    if est.__class__ is Pipeline:
        # if the estimator is a Pipeline, retrieve all steps names,
        # classes and dict
        for n, s in est.steps:
            t = [repr(s.__class__).split("\'")[1], s.get_params()]
            steps.append([n, t])
    else:
        # else the name of the unique step is the name of the
        # estimator class
        cl = repr(est.__class__).split("\'")[1]
        n = cl.split(".")[-1]
        steps.append([n, [cl, est.get_params()]])

    # produce a method configuration
    conf = {}
    conf["steps"] = steps
    conf["mapper"] = path.join(path_to_mr, mapper)
    conf["inner_reducer"] = path.join(path_to_mr, i_red)
    conf["outer_reducer"] = path.join(path_to_mr, o_red)

    check_conf(conf, cat="method")
    # output
    if out is not None:
        conf["src"] = path.basename(out)
        with open(out, 'w') as fd:
            json.dump(conf, fd, indent=2)
    return conf
Helper function to jsonify a sklearn.pipeline.Pipeline or an estimator.
dataset/ETHPy150Open BenoitDamota/mempamal/mempamal/configuration.py/JSONify_estimator