Julia support

Palladium has support for using Model objects that are implemented in the Julia programming language.

To use Palladium’s Julia support, you’ll have to install Julia 0.3 or better and the julia Python package. You’ll also need to install the PyCall library in Julia:

$ julia -e 'Pkg.add("PyCall"); Pkg.update()'

The following example also relies on the SVM Julia package. This is how you can install it:

$ julia -e 'Pkg.add("StatsBase"); Pkg.add("SVM"); Pkg.update()'

Warning

The latest PyCall version from GitHub is known to have significant performance issues. It is recommended that you install revision 120fb03 instead. To do this on Linux, change into your ~/.julia/v0.3/PyCall directory and issue the necessary git checkout command:

cd ~/.julia/v0.3/PyCall
git checkout 120fb03

Let’s now take a look at the example on how to use a model written in Julia in the examples/julia folder in the source tree of Palladium (config.py, iris.data). The configuration in that example defines the model to be of type palladium.julia.ClassificationModel:

'model': {
    '__factory__': 'palladium.julia.ClassificationModel',
    'fit_func': 'SVM.svm',
    'predict_func': 'SVM.predict',
    }

There’s two required arguments to ClassificationModel and they’re the dotted path to the Julia function used for fitting, and the equivalent for the Julia function that does the prediction. The complete description of available parameters is defined in the API docs:

class palladium.julia.AbstractModel(fit_func, predict_func, fit_kwargs=None, predict_kwargs=None, encode_labels=False)
__init__(fit_func, predict_func, fit_kwargs=None, predict_kwargs=None, encode_labels=False)

Instantiates a model with the given fit_func and predict_func written in Julia.

Parameters:
  • fit_func (str) – The dotted name of the Julia function to use for fitting. The function must take as its first two arguments the X and y arrays. All elements of the optional fit_kwargs dictionary will be passed on to the Julia function as keyword arguments. The return value of fit_func will be used as the first argument to predict_func.
  • predict_func (str) – Similar to fit_func, this is the dotted name of the Julia function used for prediction. The first argument of this function is the return value of fit_func. The second argument is the X data array. All elements of the optional fit_kwargs dictionary will be passed on to the Julia function as keyword arguments. The return value of predict_func is considered to be the target array y.
  • encode_labels (bool) – If set to True, the y target array will be automatically encoded using a sklearn.preprocessing.LabelEncoder, which is useful if you have string labels but your Julia function only accepts numeric labels.