[mlpack] Python examples

Ryan Curtin ryan at ratml.org
Mon Dec 11 14:05:35 EST 2017


On Mon, Dec 11, 2017 at 06:37:10PM +0000, Evgeny Freyman wrote:
> Hi
> 
> Cannot find any example of using MLPack from Python. Are they exists?

We haven't generated these yet---hang tight.  Before the 3.0 release
there needs to be better documentation.

In the mean time you could do the following:

>>> import mlpack
>>> dir(mlpack)
['__builtins__', '__doc__', '__file__', '__name__', '__package__',
'__path__', 'adaboost', 'approx_kfn', 'arma_numpy', 'cf',
'decision_stump', 'decision_tree', 'det', 'emst', 'fastmks',
'gmm_generate', 'gmm_probability', 'gmm_train', 'hmm_generate',
'hmm_loglik', 'hmm_train', 'hmm_viterbi', 'hoeffding_tree',
'kernel_pca', 'kfn', 'kmeans', 'knn', 'krann', 'lars',
'linear_regression', 'local_coordinate_coding', 'logistic_regression',
'lsh', 'matrix_utils', 'mean_shift', 'nbc', 'nca', 'nmf', 'pca',
'perceptron', 'preprocess_binarize', 'preprocess_describe',
'preprocess_split', 'radical', 'softmax_regression', 'sparse_coding',
'test_python_binding']

That's a list of all the bindings the mlpack package has (plus some
extras like test_python_binding and arma_numpy).  Then you can use
help() to get documentation for each.  (This help is generated from the
same documentation as the --help command for the command-line programs.)

>>> help(mlpack.logistic_regression)

That should give you all you need to actually use the bindings.  For
matrix data you can pass in your usual numpy or pandas matrices.

These are still somewhat new so speak up if you find any problems!  But
I think they are bug-free at this point and ready for production use.

-- 
Ryan Curtin    | "I know... but I really liked those ones."
ryan at ratml.org |   - Vincent


More information about the mlpack mailing list