utils/framework.py
def data_to_model(self, data: Any) -> Any:
        """
        Map data inputs to model's parameters.
        """
        if isinstance(data, dict):
            if self.data_pipeline_mapper:
                if isinstance(self.data_pipeline_mapper, dict):
                    kwargs = []
                    for input_key, model_key in self.data_pipeline_mapper.items():
                        kwargs.append((model_key, data[input_key]))
                    kwargs = dict(kwargs)
                    output = self.model(**kwargs)
                elif isinstance(self.data_pipeline_mapper, list) or isinstance(
                    self.data_pipeline_mapper, tuple
                ):
                    args = [data[input_key] for input_key in self.data_pipeline_mapper]
                    output = self.model(*args)
                else:
                    input_key = self.data_pipeline_mapper
                    output = self.model(data[input_key])
                return output
            else:
                raise ValueError("self.data_pipeline_mapper cannot be None!")
        else:
            if self.data_pipeline_mapper:
                if isinstance(self.data_pipeline_mapper, list) or isinstance(
                    self.data_pipeline_mapper, tuple
                ):
                    kwargs = dict(
                        [
                            (model_key, data[i])
                            for i, model_key in enumerate(self.data_pipeline_mapper)
                            if model_key
                        ]
                    )
                    output = self.model(**kwargs)
                else:
                    model_key = self.data_pipeline_mapper
                    kwargs = dict([(model_key, data)])
                    output = self.model(**kwargs)
                return output
            else:
                raise ValueError("self.data_pipeline_mapper cannot be None!")

        Map data inputs to model's parameters.
        
Map data inputs to model's parameters.
Map data inputs to model ' s parameters .
def data_to_model(self, data: Any) -> Any:
        if isinstance(data, dict):
            if self.data_pipeline_mapper:
                if isinstance(self.data_pipeline_mapper, dict):
                    kwargs = []
                    for input_key, model_key in self.data_pipeline_mapper.items():
                        kwargs.append((model_key, data[input_key]))
                    kwargs = dict(kwargs)
                    output = self.model(**kwargs)
                elif isinstance(self.data_pipeline_mapper, list) or isinstance(
                    self.data_pipeline_mapper, tuple
                ):
                    args = [data[input_key] for input_key in self.data_pipeline_mapper]
                    output = self.model(*args)
                else:
                    input_key = self.data_pipeline_mapper
                    output = self.model(data[input_key])
                return output
            else:
                raise ValueError("self.data_pipeline_mapper cannot be None!")
        else:
            if self.data_pipeline_mapper:
                if isinstance(self.data_pipeline_mapper, list) or isinstance(
                    self.data_pipeline_mapper, tuple
                ):
                    kwargs = dict(
                        [
                            (model_key, data[i])
                            for i, model_key in enumerate(self.data_pipeline_mapper)
                            if model_key
                        ]
                    )
                    output = self.model(**kwargs)
                else:
                    model_key = self.data_pipeline_mapper
                    kwargs = dict([(model_key, data)])
                    output = self.model(**kwargs)
                return output
            else:
                raise ValueError("self.data_pipeline_mapper cannot be None!")
def data_to_model ( self , data : Any ) -> Any : if isinstance ( data , dict ) : if self . data_pipeline_mapper : if isinstance ( self . data_pipeline_mapper , dict ) : kwargs = [ ] for input_key , model_key in self . data_pipeline_mapper . items ( ) : kwargs . append ( ( model_key , data [ input_key ] ) ) kwargs = dict ( kwargs ) output = self . model ( ** kwargs ) elif isinstance ( self . data_pipeline_mapper , list ) or isinstance ( self . data_pipeline_mapper , tuple ) : args = [ data [ input_key ] for input_key in self . data_pipeline_mapper ] output = self . model ( * args ) else : input_key = self . data_pipeline_mapper output = self . model ( data [ input_key ] ) return output else : raise ValueError ( "self.data_pipeline_mapper cannot be None!" ) else : if self . data_pipeline_mapper : if isinstance ( self . data_pipeline_mapper , list ) or isinstance ( self . data_pipeline_mapper , tuple ) : kwargs = dict ( [ ( model_key , data [ i ] ) for i , model_key in enumerate ( self . data_pipeline_mapper ) if model_key ] ) output = self . model ( ** kwargs ) else : model_key = self . data_pipeline_mapper kwargs = dict ( [ ( model_key , data ) ] ) output = self . model ( ** kwargs ) return output else : raise ValueError ( "self.data_pipeline_mapper cannot be None!" )
Map data inputs to model's parameters.
Map data inputs to model ' s parameters .
"""
        Map data inputs to model's parameters.
        """
self
data
Any