MCPcopy
hub / github.com/hyperopt/hyperopt / __init__

Method __init__

hyperopt/base.py:770–864  ·  view source on GitHub ↗

Parameters ---------- fn : callable This stores the `fn` argument to `fmin`. (See `hyperopt.fmin.fmin`) expr : hyperopt.pyll.Apply This is the `space` argument to `fmin`. (See `hyperopt.fmin.fmin`) workdir : string (or None)

(
        self,
        fn,
        expr,
        workdir=None,
        pass_expr_memo_ctrl=None,
        name=None,
        loss_target=None,
    )

Source from the content-addressed store, hash-verified

768 pyll_ctrl = pyll.as_apply(Ctrl)
769
770 def __init__(
771 self,
772 fn,
773 expr,
774 workdir=None,
775 pass_expr_memo_ctrl=None,
776 name=None,
777 loss_target=None,
778 ):
779 """
780 Parameters
781 ----------
782
783 fn : callable
784 This stores the `fn` argument to `fmin`. (See `hyperopt.fmin.fmin`)
785
786 expr : hyperopt.pyll.Apply
787 This is the `space` argument to `fmin`. (See `hyperopt.fmin.fmin`)
788
789 workdir : string (or None)
790 If non-None, the current working directory will be `workdir`while
791 `expr` and `fn` are evaluated. (XXX Currently only respected by
792 jobs run via MongoWorker)
793
794 pass_expr_memo_ctrl : bool
795 If True, `fn` will be called like this:
796 `fn(self.expr, memo, ctrl)`,
797 where `memo` is a dictionary mapping `Apply` nodes to their
798 computed values, and `ctrl` is a `Ctrl` instance for communicating
799 with a Trials database. This lower-level calling convention is
800 useful if you want to call e.g. `hyperopt.pyll.rec_eval` yourself
801 in some customized way.
802
803 name : string (or None)
804 Label, used for pretty-printing.
805
806 loss_target : float (or None)
807 The actual or estimated minimum of `fn`.
808 Some optimization algorithms may behave differently if their first
809 objective is to find an input that achieves a certain value,
810 rather than the more open-ended objective of pure minimization.
811 XXX: Move this from Domain to be an fmin arg.
812
813 """
814 self.fn = fn
815 if pass_expr_memo_ctrl is None:
816 self.pass_expr_memo_ctrl = getattr(fn, "fmin_pass_expr_memo_ctrl", False)
817 else:
818 self.pass_expr_memo_ctrl = pass_expr_memo_ctrl
819
820 self.expr = pyll.as_apply(expr)
821
822 self.params = {}
823 for node in pyll.dfs(self.expr):
824 if node.name == "hyperopt_param":
825 label = node.arg["label"].obj
826 if label in self.params:
827 raise DuplicateLabel(label)

Callers

nothing calls this directly

Calls 6

DuplicateLabelClass · 0.85
VectorizeHelperClass · 0.85
recursive_set_rng_kwargFunction · 0.85
idxs_by_labelMethod · 0.80
vals_by_labelMethod · 0.80
keysMethod · 0.80

Tested by

no test coverage detected