Exemple #1
0
 def conf_schema(self):
     json = {
         "title": "Sort Column configure",
         "type": "object",
         "description": """Sort the input frames based on a
         list of columns, which are defined in the
         `keys` of the node's conf""",
         "properties": {
             "keys": {
                 "type": "array",
                 "items": {
                     "type": "string"
                 },
                 "description": """array of columns to sort"""
             }
         },
         "required": ["keys"],
     }
     ui = {
         "keys": {
             "items": {
                 "ui:widget": "text"
             }
         },
     }
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['keys']['items']['enum'] = enums
         ui = {}
         return ConfSchema(json=json, ui=ui)
     else:
         ui = {"column": {"ui:widget": "text"}}
         return ConfSchema(json=json, ui=ui)
Exemple #2
0
 def conf_schema(self):
     json = {
         "title": "Drop Column configure",
         "type": "object",
         "description": """Drop a few columns from the dataframe""",
         "properties": {
             "columns": {
                 "type": "array",
                 "items": {
                     "type": "string"
                 },
                 "description": """array of columns to be droped"""
             }
         },
         "required": ["columns"],
     }
     ui = {
         "columns": {
             "items": {
                 "ui:widget": "text"
             }
         },
     }
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['columns']['items']['enum'] = enums
         ui = {}
         return ConfSchema(json=json, ui=ui)
     else:
         ui = {"column": {"ui:widget": "text"}}
         return ConfSchema(json=json, ui=ui)
Exemple #3
0
 def conf_schema(self):
     json = {
         "title": "DataFrame Left Merge configure",
         "type": "object",
         "description": """Left merge two dataframes of the same types""",
         "properties": {
             "column": {
                 "type": "string",
                 "description": "column name on which to do the left merge"
             }
         },
         "required": ["column"],
     }
     input_meta = self.get_input_meta()
     if (self.INPUT_PORT_LEFT_NAME in input_meta
             and self.INPUT_PORT_RIGHT_NAME in input_meta):
         col_left_inport = input_meta[self.INPUT_PORT_LEFT_NAME]
         col_right_inport = input_meta[self.INPUT_PORT_RIGHT_NAME]
         enums1 = set([col for col in col_left_inport.keys()])
         enums2 = set([col for col in col_right_inport.keys()])
         json['properties']['column']['enum'] = list(
             enums1.intersection(enums2))
         ui = {}
         return ConfSchema(json=json, ui=ui)
     else:
         ui = {"column": {"ui:widget": "text"}}
         return ConfSchema(json=json, ui=ui)
Exemple #4
0
 def conf_schema(self):
     json = {
         "title": "Rename Node configure",
         "type": "object",
         "description":
         """Rename the column name in the datafame from `old` to `new`
          defined in the node's conf""",
         "properties": {
             "old": {
                 "type":
                 "string",
                 "description":
                 """the old column name that need to be
                 replaced"""
             },
             "new": {
                 "type": "string",
                 "description": "the new column name"
             }
         },
         "required": ["old", "new"],
     }
     ui = {}
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['old']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
Exemple #5
0
 def conf_schema(self):
     json = {
         "title": "Add Sign Indicator configure",
         "type": "object",
         "description": """If the number is bigger than zero,
         the sign is 1, otherwise the sign is 0
         """,
         "properties": {
             "column": {
                 "type":
                 "string",
                 "description":
                 """the column that is used to calcuate
                 sign"""
             },
             "sign": {
                 "type": "string",
                 "description": "the sign column name",
                 "default": "sign"
             }
         },
         "required": ["column"],
     }
     ui = {}
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['column']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
Exemple #6
0
 def conf_schema(self):
     input_meta = self.get_input_meta()
     json = {
         "title": "Asset Average Configure",
         "type": "object",
         "description": """Compute the average value of the key column
         which is defined in the configuration
         """,
         "properties": {
             "column": {
                 "type":
                 "string",
                 "description":
                 """the column name in the dataframe
                 to average"""
             }
         },
         "required": ["column"],
     }
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['column']['enum'] = enums
         ui = {}
         return ConfSchema(json=json, ui=ui)
     else:
         ui = {"column": {"ui:widget": "text"}}
         return ConfSchema(json=json, ui=ui)
Exemple #7
0
 def conf_schema(self):
     json = {
         "title": "Data Splitting configure",
         "type": "object",
         "description": """Partitions device data into two parts""",
         "properties": {
             "target": {"type": "string",
                        "description": "Target column name"},
             "train_size": {"type": "number",
                            "description": """If float, represents the
                            proportion [0, 1] of the data to be assigned to
                            the training set. If an int, represents the
                            number of instances to be assigned to the
                            training set.""",
                            "default": 0.8},
             "shuffle": {"type": "boolean",
                         "description": """Whether or not to shuffle inputs
                         before splitting random_stateint"""},
             "random_state": {"type": "number",
                              "description": """If shuffle is true, seeds
                              the generator. Unseeded by default"""}
         },
         "required": ["target"],
     }
     ui = {
     }
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['target']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
Exemple #8
0
 def conf_schema(self):
     json = {
         "title": "Value Filter Node configure",
         "type": "array",
         "description": """Filter the dataframe based on a list of
         min/max values.""",
         "items": {
             "type": "object",
             "properties": {
                 "column": {
                     "type": "string",
                     "description": "dataframe column to be filered on"
                 },
                 "min": {
                     "type": "number",
                     "description": "min value, inclusive"
                 },
                 "max": {
                     "type": "number",
                     "description": "max value, inclusive"
                 }
             }
         }
     }
     ui = {}
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['items']['properties']['column']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
Exemple #9
0
 def conf_schema(self):
     json = {
         "title": "Minimum Value Node configure",
         "type": "object",
         "description": "Compute the minimum value of the key column",
         "properties": {
             "column":  {
                 "type": "string",
                 "description": "column to calculate the minimum value"
             }
         },
         "required": ["column"],
     }
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['column']['enum'] = enums
         ui = {
         }
         return ConfSchema(json=json, ui=ui)
     else:
         ui = {
             "column": {"ui:widget": "text"}
         }
         return ConfSchema(json=json, ui=ui)
Exemple #10
0
 def conf_schema(self):
     input_meta = self.get_input_meta()
     json = {
         "title": "Cvs output Configure",
         "type": "object",
         "description": """Dump the input datafram to the resulting csv file.
         the output filepath is defined as `path` in the `conf`.
         if only a subset of columns is needed for the csv file,
         enumerate the columns in the `columns` of the `conf`
         """,
         "properties": {
             "path":  {
                 "type": "string",
                 "description": """The output filepath for the csv"""
             },
             "columns": {
                 "type": "array",
                 "items": {
                     "type": "string"
                 },
                 "description": """array of columns to be selected for
                 the csv"""
             }
         },
         "required": ["path"],
     }
     ui = {}
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['columns']['items']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
 def conf_schema(self):
     json = {
         "title": "One Hot Encoding configure",
         "type": "array",
         "description":
         """Encode the categorical variable by One-hot encoding
         """,
         "items": {
             "type": "object",
             "properties": {
                 "column": {
                     "type":
                     "string",
                     "description":
                     """the source column with binary
                     encoding for the data."""
                 },
                 "prefix": {
                     "type": "string",
                     "description": "the new column name prefix."
                 },
                 "cats": {
                     "type": "array",
                     'items': {
                         "type": "integer"
                     },
                     "description": "an arrya of categories"
                 },
                 "prefix_sep": {
                     "type": "string",
                     "description": """the separator between the prefix
                     and the category.""",
                     "default": "_"
                 },
                 "dtype": {
                     "type": "string",
                     "description": "the dtype for the outputs",
                     "enum": ["float64", "float32", "int64", "int32"],
                     "default": "float64"
                 }
             }
         }
     }
     ui = {}
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['items']['properties']['column']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
Exemple #12
0
 def conf_schema(self):
     color_strings = [
         'black', 'yellow', 'blue', 'red', 'green', 'orange', 'magenta',
         'cyan'
     ]
     json = {
         "title": "Line Plot Node Configuration",
         "type": "object",
         "description": """Plot the columns as lines""",
         "properties": {
             "points": {
                 "type": "number",
                 "description": "number of data points for the chart"
             },
             "title": {
                 "type": "string",
                 "description": "the plot title"
             },
             "lines": {
                 "type": "array",
                 "items": {
                     "type": "object",
                     "title": "Line Information",
                     "properties": {
                         "column": {
                             "type": "string",
                         },
                         "label": {
                             "type": "string",
                         },
                         "color": {
                             "type": "string",
                             "enum": color_strings
                         }
                     }
                 }
             }
         },
         "required": ["points", "title", "lines"],
     }
     input_meta = self.get_input_meta()
     ui = {}
     if self.INPUT_PORT_NAME in input_meta:
         col_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_inport.keys()]
         first_item = json['properties']['lines']['items']
         first_item['properties']['column']['enum'] = enums
         return ConfSchema(json=json, ui=ui)
     else:
         return ConfSchema(json=json, ui=ui)
 def conf_schema(self):
     json = {
         "title": "Feature Importance Plot Configuration",
         "type": "object",
         "description": """Plot feature importance of each feature.
         """,
         "properties": {
             "type": {
                 "type":
                 "string",
                 "description":
                 """
                     * 'weight': the number of times a feature is used to
                                 split the data across all trees.
                     * 'gain': the average gain across all splits the
                                 feature is used in.
                     * 'cover': the average coverage across all
                                splits the feature is used in.
                     * 'total_gain': the total gain across all splits the
                                     feature is used in.
                     * 'total_cover': the total coverage across all splits
                                      the feature is used in.
                 """,
                 "enum":
                 ["weight", "gain", "cover", "total_gain", "total_cover"],
                 "default":
                 "gain"
             },
         },
         "required": ["type"],
     }
     ui = {}
     return ConfSchema(json=json, ui=ui)
 def conf_schema(self):
     json = {
         "title": "Shap Summary Plot Node",
         "type": "object",
         "description": """Plot the Shap summary""",
         "properties": {
             "max_display": {
                 "type": "integer",
                 "description": """
                    How many top features to include in the plot
                    (default is 20, or 7 for interaction plots)
                   """,
                 "default": 20
             },
             "plot_type": {
                 "type": "string",
                 "description": """
                   "dot" (default for single output), "bar" (default for
                    multi-output), "violin",
                   """,
                 "enum": ["dot", "bar", "violin"]
             }
         }
     }
     # input_meta = self.get_input_meta()
     ui = {}
     return ConfSchema(json=json, ui=ui)
Exemple #15
0
    def conf_schema(self):
        json = {
            "title": "ROC Curve Configuration",
            "type": "object",
            "description": """Plot the ROC Curve for binary classification problem.
            """,
            "properties": {
                "label":  {
                    "type": "string",
                    "description": "Ground truth label column name"
                },
                "prediction":  {
                    "type": "string",
                    "description": "prediction probablity column"
                },

            },
            "required": ["label", "prediction"],
        }
        ui = {
        }
        input_meta = self.get_input_meta()
        if self.INPUT_PORT_NAME in input_meta:
            col_from_inport = input_meta[self.INPUT_PORT_NAME]
            enums = [col for col in col_from_inport.keys()]
            json['properties']['label']['enum'] = enums
            json['properties']['prediction']['enum'] = enums
        return ConfSchema(json=json, ui=ui)
Exemple #16
0
    def conf_schema(self):
        json = {
            "title": "Stock csv data loader configure",
            "type": "object",
            "description": "Load the stock daily bar data from the csv file",
            "properties": {
                "file": {
                    "type": "string",
                    "description": "stock csv data file with full path"
                },
                "path": {
                    "type": "string",
                    "description": "path to the directory for csv files"
                }
            }
        }

        ui = {
            "file": {
                "ui:widget": "CsvFileSelector"
            },
            "path": {
                "ui:widget": "PathSelector"
            }
        }
        return ConfSchema(json=json, ui=ui)
Exemple #17
0
 def conf_schema(self):
     json = {
         "title": "Normalization Node configure",
         "type": "object",
         "description": "Normalize the columns to have zero mean and std 1",
         "properties": {
             "columns": {
                 "type": "array",
                 "description": """an array of columns that need to
                  be normalized, or excluded from normalization depending
                  on the `incldue` flag state""",
                 "items": {
                     "type": "string"
                 }
             },
             "include": {
                 "type": "boolean",
                 "description": """if set true, the `columns` need to be
                 normalized. if false, all dataframe columns except the
                 `columns` need to be normalized""",
                 "default": True
             },
         },
         "required": [],
     }
     ui = {}
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['columns']['items']['enum'] = enums
     return ConfSchema(json=json, ui=ui)
Exemple #18
0
 def conf_schema(self):
     json = {
         "title": "Forest Inferencing Node",
         "type": "object",
         "description":
         """ForestInference provides GPU-accelerated inference
         (prediction) for random forest and boosted decision tree models.
         This module does not support training models. Rather, users should
         train a model in another package and save it in a
         treelite-compatible format. (See https://github.com/dmlc/treelite)
         Currently, LightGBM, XGBoost and SKLearn GBDT and random forest
         models are supported.""",
         "properties": {
             "columns": {
                 "type":
                 "array",
                 "items": {
                     "type": "string",
                 },
                 "description":
                 """columns in the input dataframe that
     are considered as input features or not depending on `include` flag."""
             },
             "include": {
                 "type": "boolean",
                 "description": """if set true, the `columns` are treated as
                 input features if false, all dataframe columns are input
                 features except the `columns`""",
                 "default": True
             },
             "file": {
                 "type": "string",
                 "description": """The saved model file"""
             },
             "prediction": {
                 "type": "string",
                 "description": "the column name for prediction",
                 "default": "predict"
             },
             "model_type": {
                 "type": "string",
                 "description": """Format of the saved treelite model to be
                     load""",
                 "enum": ["xgboost", "lightgbm"],
                 "default": "xgboost"
             },
         },
         "required": ['file'],
     }
     ui = {
         "file": {
             "ui:widget": "FileSelector"
         },
     }
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['columns']['items']['enum'] = enums
     return ConfSchema(json=json, ui=ui)
Exemple #19
0
 def conf_schema(self):
     json = {
         "title": "XGBoost Inference Node configure",
         "type": "object",
         "description": """make predictions for all the input
          data points""",
         "properties": {
             "prediction": {
                 "type": "string",
                 "description": "the column name for prediction",
                 "default": "predict"
             },
             "pred_contribs": {
                 "type": "boolean",
                 "description":
                 """
                 When this is True the output will be a matrix of size
                 (nsample, nfeats + 1) with each record indicating the
                 feature contributions (SHAP values) for that prediction.
                 The sum of all feature contributions is equal to the raw
                  untransformed margin value of the prediction. Note the
                   final column is the bias term.
                 """,
                 "default": False
             }
         },
         "required": [],
     }
     ui = {}
     return ConfSchema(json=json, ui=ui)
Exemple #20
0
 def conf_schema(self):
     task_graph = self.task_graph
     # replacementObj = self.replacementObj
     # # cache_key, task_graph, replacementObj = self._compute_has
     # cache_key, task_graph, replacementObj = self._compute_hash_key()
     # if cache_key in CACHE_SCHEMA:
     #     return CACHE_SCHEMA[cache_key]
     # get's the input when it gets the conf
     input_meta = self.get_input_meta()
     json = {}
     if self.INPUT_CONFIG in input_meta:
         conf = input_meta[self.INPUT_CONFIG]
         if 'context' in conf:
             json = deepcopy(_CONF_JSON)
             metrics = []
             # task_graph.build(replace=replacementObj)
             for t in task_graph:
                 node_id = t.get('id')
                 if node_id != '':
                     node = task_graph[node_id]
                     all_ports = node.ports_setup()
                     for port in all_ports.outports.keys():
                         types = all_ports.outports[port][
                             PortsSpecSchema.port_type]
                         if types == float:
                             metrics.append(node_id + '.' + port)
                         elif (isinstance(types, list)
                               and types[0] == float):
                             metrics.append(node_id + '.' + port)
             context = conf['context']
             json['properties']['parameters']['items']['properties'][
                 'name']['enum'] = list(context.keys())
             json['properties']['metrics']['items']['enum'] = metrics
             if 'metrics' in self.conf:
                 json['properties']['best']['properties']['metric'][
                     'enum'] = self.conf['metrics']
             options = json['properties']['parameters']['items'][
                 'dependencies']['name']['oneOf']
             for var in context.keys():
                 if (context[var]['type'] == 'number'
                         or context[var]['type'] == 'string'):
                     obj = {
                         "properties": {
                             "name": {
                                 "type": "string",
                                 "enum": [var]
                             },
                             "search": {
                                 "$ref":
                                 "#/definitions/{}".format(
                                     context[var]['type'])
                             }
                         }
                     }
                     options.append(obj)
     ui = {"tune": {"local_dir": {"ui:widget": "PathSelector"}}}
     out_schema = ConfSchema(json=json, ui=ui)
     # CACHE_SCHEMA[cache_key] = out_schema
     return out_schema
 def conf_schema(self):
     json = {
         "title": "Backtest configure",
         "type": "object",
         "description": """compute the `strategy_returns` by assuming invest
          `signal` amount of dollars for each of the time step.""",
     }
     ui = {
     }
     return ConfSchema(json=json, ui=ui)
Exemple #22
0
 def conf_schema(self):
     json = {
         "title": "XGBoost Node configure",
         "type": "object",
         "description":
         """convert the predicted next day return as trading actions
         """,
         "properties": {},
     }
     ui = {}
     return ConfSchema(json=json, ui=ui)
Exemple #23
0
 def conf_schema(self):
     json = {
         "title": "Calculate Sharpe Ratio configure",
         "type": "object",
         "description": """Compute the yearly Sharpe Ratio from the
         input dataframe `strategy_returns` column. Assume it is
         daily return. Asumes 252 trading days per year
         """,
     }
     ui = {
     }
     return ConfSchema(json=json, ui=ui)
Exemple #24
0
 def conf_schema(self):
     json = {
         "title":
         "Simple Portfolio Node configure",
         "type":
         "object",
         "description":
         """Average the strategy returns for all the
         assets """,
     }
     ui = {}
     return ConfSchema(json=json, ui=ui)
Exemple #25
0
    def conf_schema(self):
        json = {
            "title":
            "Run dask compute",
            "type":
            "object",
            "description":
            "If the input is a dask or dask_cudf dataframe "
            "then run compute on it, otherwise pass through."
        }

        return ConfSchema(json=json)
Exemple #26
0
 def conf_schema(self):
     json = {
         "title":
         "Add Returen Feature Node configure",
         "type":
         "object",
         "description":
         """Add the rate of of return column based
         on the `close` price for each of the asset in the dataframe.
         """,
     }
     ui = {}
     return ConfSchema(json=json, ui=ui)
 def conf_schema(self):
     json = {
         "title":
         "Asset indicator configure",
         "type":
         "object",
         "description":
         """Add the indicator column in the dataframe which
          set 1 at the beginning of the each of the assets, assuming the
          rows are sorted so same asset are grouped together""",
     }
     ui = {}
     return ConfSchema(json=json, ui=ui)
Exemple #28
0
 def conf_schema(self):
     json = {
         "title": "Scatter Plot Configuration",
         "type": "object",
         "description": """Make a Scatter Plot.
         """,
         "properties": {
             "points": {
                 "type": "number",
                 "description": "number of data points for the chart"
             },
             "title": {
                 "type": "string",
                 "description": "the plot title"
             },
             "col_x": {
                 "type": "string",
                 "description": "column used for X-axis"
             },
             "col_x_scale": {
                 "type": "string",
                 "description": "X-axis scale",
                 "enum": ["DateScale", "LinearScale"],
                 "default": "LinearScale"
             },
             "col_y": {
                 "type": "string",
                 "description": "column used for Y-axis"
             },
             "col_y_scale": {
                 "type": "string",
                 "description": "Y-axis scale",
                 "enum": ["DateScale", "LinearScale"],
                 "default": "LinearScale"
             },
             "col_color": {
                 "type": "string",
                 "description": "column used for color"
             }
         },
         "required": ["points", "title", "col_x", "col_y"],
     }
     ui = {}
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['col_x']['enum'] = enums
         json['properties']['col_y']['enum'] = enums
         json['properties']['col_color']['enum'] = enums
     return ConfSchema(json=json, ui=ui)
Exemple #29
0
 def conf_schema(self):
     full_schema = super().conf_schema()
     full_schema_json = full_schema.json
     ui = full_schema.ui
     json = {
         "title": "CustXGBoostNode configure",
         "type": "object",
         "description": "Enter your node description here",
         "properties": {}
     }
     item_dict = full_schema_json['properties']['subnodes_conf'][
         'properties']
     for key in item_dict.keys():
         json['properties'][key] = item_dict[key]
     return ConfSchema(json=json, ui=ui)
Exemple #30
0
    def conf_schema(self):
        json = {
            "title": "Stock name csv file loader configure",
            "type": "object",
            "description": "Load the stock name data from the csv file",
            "properties": {
                "file": {
                    "type": "string",
                    "description": "stock name csv file with full path"
                }
            },
            "required": ["file"],
        }

        ui = {"file": {"ui:widget": "CsvFileSelector"}}
        return ConfSchema(json=json, ui=ui)