rust-ml / rust-ml/linfa

Python bindings

Open
#220 18 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Rust
Stars
4.7k
Forks
334
Avg merge
39m
Merged PRs (30d)
1

Description

We should add Python bindings to the public API of linfa crates. This will allow us to fairly benchmark linfa against scikit-learn, which also uses a Python API, as well as making linfa easier to use, allowing for wider adoption. This process can be done piece by piece. I suggest we start with linfa-clustering, since that's the most-used linfa crate and also has prior art behind it.

Questions

  • How close do we make the API to scikit-learn? Do we want exact parity?
  • How do we support numpy in our API without lots of data copying?
  • linfa makes heavy use of generics, but for Python bindings we need to pick one monomorphization to build. For type params like F we can just pick f64, but for other it's less clear cut. We may also need to choose between different params at runtime instead of compile time. Do we use an enum? A trait object?
  • Similarly, which features do we want to build linfa with?

We'll likely put all the bindings into one Python package, so that we don't build multiple copies of linfa across multiple packages.

Prior Art
When @LukeMathWalker first released linfa, he also released Python bindings here, for benchmarking against scikit-learn. AFAIK these bindings only support KMeans, and they are also 3 years old, but they should provide a good starting point.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the public API of the linfa-clustering crate and the prior art in the linked linfa-python project, which supports KMeans. The work is not yet defined: first establish the Python package structure, scikit-learn compatibility, NumPy data handling, generic type choices, and enabled features before implementing bindings and benchmarks.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python, rust, scikit-learn
Domain
api, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.