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_columns = self.get_input_columns() if self.INPUT_PORT_NAME in input_columns: col_from_inport = input_columns[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)
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)
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_columns = self.get_input_columns() if (self.INPUT_PORT_LEFT_NAME in input_columns and self.INPUT_PORT_RIGHT_NAME in input_columns): col_left_inport = input_columns[self.INPUT_PORT_LEFT_NAME] col_right_inport = input_columns[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)
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_columns = self.get_input_columns() if self.INPUT_PORT_NAME in input_columns: col_from_inport = input_columns[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)
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_columns = self.get_input_columns() if self.INPUT_PORT_NAME in input_columns: col_from_inport = input_columns[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)
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)
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)
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)
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_columns = self.get_input_columns() ui = {} if self.INPUT_PORT_NAME in input_columns: col_inport = input_columns[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": "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)
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)
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": "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)
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)
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)
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)
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)
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": "Simple Portfolio Node configure", "type": "object", "description": """Average the strategy returns for all the assets """, } ui = {} return ConfSchema(json=json, ui=ui)
def conf_schema(self): 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(): if all_ports.outports[port][ PortsSpecSchema.port_type] == 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": "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)
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)
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): 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)
def conf_schema(self): json = { "title": "XGBoost Export Configure", "type": "object", "description": """Export the xgboost model to a file """, "properties": { "path": { "type": "string", "description": """The output filepath for the csv""" } }, "required": ["path"], } ui = {} return ConfSchema(json=json, ui=ui)
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)
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" }, }, "required": [], } ui = {} return ConfSchema(json=json, ui=ui)
def conf_schema(self): json = { "title": "Linear Embeding configure", "type": "object", "description": """Project the features randomly and linearly to a space of different dimension. It generates the random projection matrix of size feature_dim x out_dimension and does dot product with the input dataframe""", "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 }, "out_dimension": { "type": "integer", "minimum": 0, "description": """the projected dimension size""" }, "seed": { "type": "integer", "description": """the seed number for random projection""" } }, "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)
def conf_schema(self): json = { "title": "Cumulative Return Configuration", "type": "object", "description": """Plot the P & L graph from the `strategy_returns` column. """, "properties": { "points": { "type": "number", "description": "number of data points for the chart" }, "label": { "type": "string", "description": "Label for the line plot" }, }, "required": ["points"], } ui = { } return ConfSchema(json=json, ui=ui)
def conf_schema(self): json = { "title": "Asset Filter Node configure", "type": "object", "description": "select the asset based on asset id", "properties": { "asset": { "type": "number", "description": "asset id number" } }, "required": ["asset"], } ui = {} input_columns = self.get_input_columns() if self.INPUT_MAP_NAME in input_columns: col_from_inport = input_columns[self.INPUT_MAP_NAME] enums = col_from_inport['asset'] enumNames = col_from_inport['asset_name'] json['properties']['asset']['enum'] = enums json['properties']['asset']['enumNames'] = enumNames return ConfSchema(json=json, ui=ui)