:mod:`quartic_sdk.model.BaseSpectralModel` ========================================== .. py:module:: quartic_sdk.model.BaseSpectralModel Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quartic_sdk.model.BaseSpectralModel.BaseSpectralModel .. class:: BaseSpectralModel(name: str, description: str = '', log_level: str = 'INFO') A Base Class Model for Wrapping Spectral Models into Quartic Deployments. User needs to inherit this class and override the predict method with all the post model training steps such as, preprocessing, prediction, postprocessing the pandas dataframe passed to :func: `predict` during real time prediction. Note: Please do not overwrite method :func: `save` as it contains utilities to validate and deploy models to the Quartic AI Platform Parameters ---------- name : Name of the model to be saved in Quartic AI Platform description : Description of the current model log_level : Log Level for logs created/executed during run time i.e. during real time predictions Attributes ---------- name : Name of the model to be saved in Quartic AI Platform description : description of model log_level : Log level log : Logger instance which can be used to set run time logs ex: self.log.info("Example Log") Methods ------- save : private save method to save deploy model to the Quartic AI Platform predict : abstract predict method which needs to overridden Examples -------- class MyModel(BaseSpectralModel): def __init__(self, model): self.model = model super().__init__('MyModel', 'model description', 'INFO') def preprocess(self, input_df): transformed_df = custom_transform(input_df) return transformed_df def postprocess(self, input_df): transformed_df = custom_transform_post(input_df) return transformed_df def predict(self, input_df): pre_transformed_df = self.preprocess(input_df) prediction_df = self.model.predict(pre_transformed_df) self.log.info("Test Log") return postprocess(prediction_df)['output_column'] # pandas Series lr = LinearRegression() lr.train(input_data) my_model = MyModel(lr) my_model.save(client, 'my_spectralmodel_output', ['1460000.0','1460001.0','1460002.0'], Tag('Spectral'), Tag('Target'), input_data, None, 12) .. method:: save(self, client, output_tag_name: str, feature_wavelengths: List[str], spectral_tag: int, target_tag: int, test_df: pandas.DataFrame, ml_node: int = None, future_window: int = None) :param client: Quartic APIClient :param output_tag_name: name for Prediction output tag :param feature_wavelengths: Feature wavelengths of spectral_tag used in model :param spectral_tag: Spectral tag_id :param target_tag: Target tag id to specify the parent of current soft tag :param test_df: Test input dataframe to validate input and prediction output in agreement with Quartic AI Platform :param ml_node: Optional - ML Node ID if deployment of model needs to be done to specific node :future_window: Optional - time in ms(int) :return: None on successfully storing the model to the Quartic AI Platform .. method:: predict(self, input_df: pandas.DataFrame) -> pandas.Series :abstractmethod: Abstract method for custom predict method :param input_df: Input Data frame for prediction :return: Returns pd