Back to Community
CustomFactor return two values?

Im in the research and I'm building an algorithm that builds a machine learning classifier for every stock in a list of stock and then returns the prediction for a certain day. The only issue is I also want to base their predictions with some form of evaluation metric. It would take too long to build the models again in a different class and return the metric in that fashion and when i try to make the return a list I get errors because I don't know how to handle it. does anyone know a way to do it so that CustomFactor can return two values.

right now i have to values and this is my 'return' statement

out[:] = [predictions, f]  

it works but is completely unusable in the pipeline

1 response

Hi Nathan,

Here is an example:

class myCustomFactor(CustomFactor):  
    inputs = [USEquityPricing.close]  
    outputs = ['mean', 'volatility']  
    def compute(self, today, assets, out, close):  
        out[:].mean = numpy.nanmean(close, axis=0)  
        out[:].volatility = numpy.nanstd(close, axis=0)