
Custom algorithm template
You can use the following custom algorithm template to help get you started.
BaseAlgo class
From base import BaseAlgo
.
class CustomAlgoTemplate(BaseAlgo): def __init__(self, options): # Option checking & initializations here pass def fit(self, df, options): # Fit an estimator to df, a pandas DataFrame of the search results pass def partial_fit(self, df, options): # Incrementally fit a model pass def apply(self, df, options): # Apply a saved model # Modify df, a pandas DataFrame of the search results return df @staticmethod def register_codecs(): # Add codecs to the codec manager pass
Using the template above in a search, as in the example below, reflects the input data back to the search.
| fit CustomAlgoTemplate *
These are all described in detail in the $SPLUNK_HOME/etc/apps/Splunk_ML_Toolkit/bin/base.py
BaseAlgo class as shown below.
PREVIOUS Write a Python algorithm class |
NEXT Running process and method calling conventions |
This documentation applies to the following versions of Splunk® Machine Learning Toolkit: 4.4.0, 4.4.1, 4.4.2, 4.5.0, 5.0.0, 5.1.0, 5.2.0, 5.2.1, 5.2.2, 5.3.0, 5.3.1, 5.3.3, 5.4.0, 5.4.1
Feedback submitted, thanks!