def node_from_yaml(node_spec):
     """ Create the node based on the node_spec """
     node_spec = copy.deepcopy(node_spec)
     # call parent class method for most of the work
     node_spec["parameters"], flow_template = \
          ParameterOptimizationBase.check_parameters(node_spec["parameters"])
     # check grid search specific params
     optimization = node_spec["parameters"].pop("optimization")
     assert("ranges" in optimization), "Grid Search needs *ranges* parameter"
     BaseNode.eval_dict(optimization)
     node_obj = GridSearchNode(ranges=optimization["ranges"], 
                               flow_template=flow_template, 
                               **node_spec["parameters"])
     return node_obj
 def node_from_yaml(node_spec):
     """ Create the node based on the node_spec """
     node_spec = copy.deepcopy(node_spec)
     # call parent class method for most of the work
     node_spec["parameters"], flow_template = \
         ParameterOptimizationBase.check_parameters(node_spec["parameters"])
     if node_spec["parameters"].has_key("optimization"):
         BaseNode.eval_dict(node_spec["parameters"]["optimization"])
         # since pattern search specific params are all optional, add them to
         # **kwargs and let the __init__ do the default assignments
         for key, value in node_spec["parameters"].pop("optimization").iteritems():
             node_spec["parameters"][key] = value
     node_obj = PatternSearchNode(flow_template=flow_template, 
                                  **node_spec["parameters"])
     return node_obj
示例#3
0
 def node_from_yaml(node_spec):
     """ Create the node based on the node_spec """
     node_spec = copy.deepcopy(node_spec)
     # call parent class method for most of the work
     node_spec["parameters"], flow_template = \
          ParameterOptimizationBase.check_parameters(node_spec["parameters"])
     # check grid search specific params
     optimization = node_spec["parameters"].pop("optimization")
     assert ("ranges"
             in optimization), "Grid Search needs *ranges* parameter"
     BaseNode.eval_dict(optimization)
     node_obj = GridSearchNode(ranges=optimization["ranges"],
                               flow_template=flow_template,
                               **node_spec["parameters"])
     return node_obj
示例#4
0
 def node_from_yaml(node_spec):
     """ Create the node based on the node_spec """
     node_spec = copy.deepcopy(node_spec)
     # call parent class method for most of the work
     node_spec["parameters"], flow_template = \
         ParameterOptimizationBase.check_parameters(node_spec["parameters"])
     if node_spec["parameters"].has_key("optimization"):
         BaseNode.eval_dict(node_spec["parameters"]["optimization"])
         # since pattern search specific params are all optional, add them to
         # **kwargs and let the __init__ do the default assignments
         for key, value in node_spec["parameters"].pop(
                 "optimization").iteritems():
             node_spec["parameters"][key] = value
     node_obj = PatternSearchNode(flow_template=flow_template,
                                  **node_spec["parameters"])
     return node_obj
示例#5
0
    def check_parameters(param_spec):
        """ Check input parameters of existence and appropriateness """
        assert("nodes" in param_spec and "optimization" in param_spec),\
                   "Parameter Optimization node requires specification of a " \
                   "list of nodes and optimization algorithm!"

        validation_set = param_spec.get("validation_set", {})
        validation_set["splits"] = validation_set.get("splits", 5)
        validation_set["split_node"] = validation_set.get(
            "split_node", {
                'node': 'CV_Splitter',
                'parameters': {
                    'splits': validation_set["splits"]
                }
            })

        evaluation = param_spec.get("evaluation", {})
        evaluation["ir_class"] = evaluation.get("ir_class", "Target")
        evaluation["performance_sink_node"] = evaluation.get(
            "performance_sink_node", {
                'node': 'Classification_Performance_Sink',
                'parameters': {
                    'ir_class': evaluation["ir_class"]
                }
            })

        # build flow template
        nodes_spec = param_spec.pop("nodes")
        flow_template = [{
            'node': 'External_Generator_Source_Node'
        }, validation_set["split_node"]]
        flow_template.extend(nodes_spec)
        flow_template.append(evaluation["performance_sink_node"])

        # Evaluate all remaining parameters
        BaseNode.eval_dict(param_spec)

        # params with defaults in __init__ have to be added to param_spec dict
        if validation_set.has_key("runs"):
            param_spec["runs"] = validation_set["runs"]
        if evaluation.has_key("metric"):
            param_spec["metric"] = evaluation["metric"]
        if evaluation.has_key("std_weight"):
            param_spec["std_weight"] = evaluation['std_weight']

        return param_spec, flow_template
示例#6
0
    def check_parameters(param_spec):
        """ Check input parameters of existence and appropriateness """
        assert("nodes" in param_spec and "optimization" in param_spec), \
            "Parameter Optimization node requires specification of a " \
            "list of nodes and optimization algorithm!"
        
        validation_set = param_spec.pop("validation_set", {})
        validation_set["splits"] = validation_set.get("splits",5)
        validation_set["split_node"] = validation_set.get("split_node",
                           {'node': 'CV_Splitter', 
                            'parameters': {'splits': validation_set["splits"]}})

        evaluation = param_spec.pop("evaluation", {})
        evaluation["ir_class"] = evaluation.get("ir_class", "Target")
        evaluation["performance_sink_node"] = \
            evaluation.get("performance_sink_node",
                           {'node': 'Classification_Performance_Sink',
                            'parameters': {'ir_class': evaluation["ir_class"]}})
        
        # build flow template
        nodes_spec = param_spec.pop("nodes")
        flow_template = [{'node': 'External_Generator_Source_Node'},
                         validation_set["split_node"]]
        flow_template.extend(nodes_spec)
        flow_template.append(evaluation["performance_sink_node"])
        
        # Evaluate all remaining parameters
        BaseNode.eval_dict(param_spec)
        
        # params with defaults in __init__ have to be added to param_spec dict
        if validation_set.has_key("runs"): 
            param_spec["runs"] = validation_set["runs"] 
        if evaluation.has_key("metric"): 
            param_spec["metric"] = evaluation["metric"]
        if evaluation.has_key("inverse_metric"):
            param_spec["inverse_metric"] = evaluation["inverse_metric"]
        if evaluation.has_key("std_weight"): 
            param_spec["std_weight"] = evaluation['std_weight']
        
        return param_spec, flow_template