Print Page  
Advanced Functions / AI Factor
AIFactor("AI Factor Name", "Predictor Name")
Full Description

Returns the predictions from a trained AI Predictor. Mainly for use in 'live' strategies to rebalance, or to screen for new ideas. It can also be used in backtests with some restrictions (see below). Please note that AIFactor() can return N/A if more than 30% of the features are missing.

Parameters

“AI Factor Name”: The name of the AI Factor.
“Predictor Name”: The name of the AI Factor Predictor.

How to use

Create a predictor on the Prediction tab in the AI Factor. When the training is complete, click on the fx icon next to the predictor's name. This will pop up a dialog with additional information including the pre-filled AIFactor() formula which can be used in ranking system formulas and buy/sell rules.

Usage notes for backtests

Although AIFactor() primary use case is for inference, it can be used for limited backtesting to verify, for example, the results with more recent market cycles. Please note the following:

1) Prediction is an expensive, slow running operation since it involves sending the dataset for the chosen universe to the AI backend, normalizing the data and calculating the predictions for the universe. For this reason, in backtests it can only be used up to 5 years in the past. To run longer backtests using AI predictions, please see AIFactorValidation().

2) When backtesting a machine learning model, it is crucial that the backtest does not overlap with the training data to ensure the evaluation of the model's performance is realistic and unbiased. Overlap can lead to overfitting and artificially inflated returns. To prevent this, usage of the AIFactor()  dates which overlap the training dates of the AI Factor will generate an error.

Examples

1) In a Ranking system, simply add a Stock Formula and use the AIFactor() function as the Formula. You can use multiple AIFactors() in a ranking system or combine AIFactor() with other typical ranking system rules.

2) To run a long/short screen using the best/worst decile predictions, do the following:

  • Go to the screen settings and choose “Long/Short” in Method
  • Select “Quick Rank” for Ranking, and enter the prediction formula
  • Set the Quick Rank Method to “Percentile NA Neutral”
  • Go to Rules and in the Long Rule enter Rank > 90
  • Got to Hedge and in the Short Rule enter Rank < 10
  • Run a backtest

3) In a Screen rule to get the top decile:

FRank(`AIFactor("My AI Factor", "lightgbm II predictor")`,#All, #Desc) > 90

4) In a Screen rule to get the bottom decile:

FRank(`AIFactor("My AI Factor", "lightgbm II predictor")`,#All, #Desc, #NANeutral) < 10

Note the use of #NANeutral for the incl_na parameter