neuroscout/populate/transform.py
def apply_transformation(self, new_name, function, func_args={}, **filter):
        """ Queries EFs, applies transformation, and saves as new EF/Predictor
        Args:
            new_name - Feature/predictor name for transformed results
            func - Function name to apply
            func_args - keyword args for transformation function
            filter - arguments to filter ExtractedFeatures
        Returns:
            Database id of new ExtractedFeature
        """
        # Query EFs
        efs = self.efs.filter_by(**filter)

        if efs.count() > 0:
            # Create EF
            ext_name = efs.first().extractor_name

            new_ef = ExtractedFeature(
                extractor_name=ext_name, feature_name=new_name,
                active=True, sha1_hash=hash_data(ext_name + new_name),
                transformed=True,
                **self._get_annotations(new_name, ext_name))
            db.session.add(new_ef)
            db.session.commit()

            # Apply function, get new EE values, and create models
            ee_results = getattr(self, function)(
                self._ef_to_df(efs), **func_args)

            # Create EEs and predictor
            db.session.bulk_save_objects(
                [ExtractedEvent(ef_id=new_ef.id, **ee) for ee in ee_results]
                )
            db.session.commit()

            # Create Predictors from EFs
            create_predictors([new_ef], self.dataset_name, self.task_name,
                              percentage_include=False)

            return new_ef.id
        else:
            print(f"No EFs match transformation {function}")
 Queries EFs, applies transformation, and saves as new EF/Predictor
        Args:
            new_name - Feature/predictor name for transformed results
            func - Function name to apply
            func_args - keyword args for transformation function
            filter - arguments to filter ExtractedFeatures
        Returns:
            Database id of new ExtractedFeature
        
Queries EFs, applies transformation, and saves as new EF/Predictor
Args:
new_name - Feature/predictor name for transformed results
func - Function name to apply
func_args - keyword args for transformation function
filter - arguments to filter ExtractedFeatures
Returns:
Database id of new ExtractedFeature
Queries EFs applies transformation and saves as new EF / Predictor Args : new_name - Feature / predictor name for transformed results func - Function name to apply func_args - keyword args for transformation function filter - arguments to filter ExtractedFeatures Returns : Database id of new ExtractedFeature
def apply_transformation(self, new_name, function, func_args={}, **filter):
        efs = self.efs.filter_by(**filter)
        if efs.count() > 0:
            ext_name = efs.first().extractor_name
            new_ef = ExtractedFeature(
                extractor_name=ext_name, feature_name=new_name,
                active=True, sha1_hash=hash_data(ext_name + new_name),
                transformed=True,
                **self._get_annotations(new_name, ext_name))
            db.session.add(new_ef)
            db.session.commit()
            ee_results = getattr(self, function)(
                self._ef_to_df(efs), **func_args)
            db.session.bulk_save_objects(
                [ExtractedEvent(ef_id=new_ef.id, **ee) for ee in ee_results]
                )
            db.session.commit()
            create_predictors([new_ef], self.dataset_name, self.task_name,
                              percentage_include=False)
            return new_ef.id
        else:
            print(f"No EFs match transformation {function}")
def apply_transformation ( self , new_name , function , func_args = { } , ** filter ) : efs = self . efs . filter_by ( ** filter ) if efs . count ( ) > 0 : ext_name = efs . first ( ) . extractor_name new_ef = ExtractedFeature ( extractor_name = ext_name , feature_name = new_name , active = True , sha1_hash = hash_data ( ext_name + new_name ) , transformed = True , ** self . _get_annotations ( new_name , ext_name ) ) db . session . add ( new_ef ) db . session . commit ( ) ee_results = getattr ( self , function ) ( self . _ef_to_df ( efs ) , ** func_args ) db . session . bulk_save_objects ( [ ExtractedEvent ( ef_id = new_ef . id , ** ee ) for ee in ee_results ] ) db . session . commit ( ) create_predictors ( [ new_ef ] , self . dataset_name , self . task_name , percentage_include = False ) return new_ef . id else : print ( f"No EFs match transformation {function}" )
Queries EFs, applies transformation, and saves as new EF/Predictor
Args:
new_name - Feature/predictor name for transformed results
func - Function name to apply
func_args - keyword args for transformation function
filter - arguments to filter ExtractedFeatures
Returns:
Database id of new ExtractedFeature
Queries EFs applies transformation and saves as new EF / Predictor Args : new_name - Feature / predictor name for transformed results func - Function name to apply func_args - keyword args for transformation function filter - arguments to filter ExtractedFeatures Returns : Database id of new ExtractedFeature
""" Queries EFs, applies transformation, and saves as new EF/Predictor
        Args:
            new_name - Feature/predictor name for transformed results
            func - Function name to apply
            func_args - keyword args for transformation function
            filter - arguments to filter ExtractedFeatures
        Returns:
            Database id of new ExtractedFeature
        """ # Query EFs # Create EF # Apply function, get new EE values, and create models # Create EEs and predictor # Create Predictors from EFs
self
new_name
function
func_args