Rust language bindings for the LIBLINEAR C/C++ library.

Overview

Latest Version deps.svg docs MIT

liblinear-rs

Rust bindings for the liblinear C/C++ library. Provides a thin (but rustic) wrapper around the original C-interface exposed by the library.

Usage

Use the liblinear::Builder API to train a model on sparse features and predict the class of a new instance.

extern crate liblinear;
use liblinear::*;

let x: Vec<Vec<(u32, f64)>> = vec![
        vec![(1, 0.1), (3, 0.2)],
        vec![(3, 9.9)],
        vec![(1, 0.2), (2, 3.2)],
    ];
let y = vec![0.0, 1.0, 0.0];

let mut model_builder = liblinear::Builder::new();
model_builder
    .problem()
    .input_data(util::TrainingInput::from_sparse_features(y, x).unwrap())
    .bias(0f64);
model_builder
    .parameters()
    .solver_type(SolverType::L2R_LR)
    .stopping_criterion(0.1f64)
    .constraints_violation_cost(0.1f64)
    .regression_loss_sensitivity(1f64);

let model = model_builder.build_model().unwrap();
assert_eq!(model.num_classes(), 2);

let predicted_class = model
    .predict(util::PredictionInput::from_sparse_features(vec![(1u32, 2.2f64)]).unwrap())
    .unwrap();
println!(predicted_class);

More examples can be found in the bundled unit tests.

Changelog

1.0.0 - Update liblinear to v230 (breaking changes), minor changes and fixes.
0.1.1 - Added readme, minor documentation fixes.
0.1.0 - Initial release.

You might also like...
mxnet Rust Bindings

mxnet Rust Bindings This is a work in progress. Contributions gladly accepted! The mxnet crate defines a high-level Rust API for mxnet using the mxnet

Rust bindings for darknet

Rust bindings for darknet Darknet: Convolutional Neural Networks todo rewrite the demo function used in yolo.c in rust Examples Link existing files an

SlintDotnet is a C# bindings project to enable developers to use Slint UI with .NET C#

SlintDotnet (Alpha) Slint is a UI toolkit that supports different programming languages. SlintDotnet is the integration with .NET C#. ⚠️ This is exper

A tour of rust's language features

Tour of Rust Welcome to the source repo of Tour of Rust. Goals This project is meant to give an experienced programmer a swift introduction to Rust as

Rust-like syntax for OpenGL Shading Language

Rust-like syntax for GLSL glassful translates a small subset of Rust to OpenGL Shading Language. Besides one's personal preferences regarding Rust-lik

🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧
🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧

🐉 rust-gpu Rust as a first-class language and ecosystem for GPU graphics & compute shaders Current Status 🚧 Note: This project is still heavily in d

A collection of CC-BY-SA course material to teach the Rust programming language, in different formats, levels, and focus points

A collection of CC-BY-SA course material to teach the Rust programming language, in different formats, levels, and focus points. Contact me for remote and on-site trainings!

[WIP] An experimental Java-like language and it's virtual machine, for learning Java and JVM.

Sky VM An experimental Java-like language and it's virtual machine, for learning Java and JVM. Dependencies Rust (rust-lang/rust) 2021 Edition, dual-l

Masked Language Model on Wasm
Masked Language Model on Wasm

Masked Language Model on Wasm This project is for OPTiM TECH BLOG. Please see below: WebAssemblyを用いてBERTモデルをフロントエンドで動かす Demo Usage Build image docker

Comments
  • Failing to link on MacOS

    Failing to link on MacOS

    When trying to add liblinear-rs as a dependecy to my rust project I am getting this error

    error: linking with `cc` failed: exit code: 1
    ...
      = note: ld: library not found for -lstdc++
              clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    This seems to be because I am compiling on a mac it seems like stdc++ has been deprecated https://stackoverflow.com/questions/51060596/ld-library-not-found-for-lstdc-6

    bug 
    opened by KevinCybura 3
Owner
Madeesh Kannan
Petty dabbler in something or the other. Mostly in the other.
Madeesh Kannan
Rust language bindings for Faiss

Faiss-rs This project provides Rust bindings to Faiss, the state-of-the-art vector search and clustering library. Installing as a dependency Currently

Eduardo Pinho 86 Jan 7, 2023
🌾 High-performance Text processing library for the Thai language, built with Rust and exposed as a Python package.

Thongna ?? Thongna (ท้องนา) is a high-performance text processing library for the Thai language, built with Rust and exposed as a Python package. Insp

fr4nk 3 Aug 17, 2024
Rust bindings for the C++ api of PyTorch.

tch-rs Rust bindings for the C++ api of PyTorch. The goal of the tch crate is to provide some thin wrappers around the C++ PyTorch api (a.k.a. libtorc

Laurent Mazare 2.3k Jan 1, 2023
Rust bindings for TensorFlow Lite

Rust bindings for TensorFlow Lite This crates provides TensorFlow Lite APIs. Please read the API documentation on docs.rs Using the interpreter from a

Boncheol Gu 84 Dec 11, 2022
Rust bindings for XGBoost.

rust-xgboost Rust bindings for the XGBoost gradient boosting library. Documentation Basic usage example: extern crate xgboost; use xgboost::{paramete

Dave Challis 79 Nov 28, 2022
Locality Sensitive Hashing in Rust with Python bindings

lsh-rs (Locality Sensitive Hashing) Locality sensitive hashing can help retrieving Approximate Nearest Neighbors in sub-linear time. For more informat

Ritchie Vink 65 Jan 2, 2023
OpenAI Gym bindings for Rust

gym-rs OpenAI gym binding for Rust. Actively maintained! If you have any problem just create an issue. Install Just install the requierements layed ou

Mr.Robb 45 Dec 11, 2022
High-level non-blocking Deno bindings to the rust-bert machine learning crate.

bertml High-level non-blocking Deno bindings to the rust-bert machine learning crate. Guide Introduction The ModelManager class manages the FFI bindin

Carter Snook 14 Dec 15, 2022
An example of using TensorFlow rust bindings to serve trained machine learning models via Actix Web

Serving TensorFlow with Actix-Web This repository gives an example of training a machine learning model using TensorFlow2.0 Keras in python, exporting

Kyle Kosic 39 Dec 12, 2022
Docker for PyTorch rust bindings `tch`. Example of pretrain model.

tch-rs-pretrain-example-docker Docker for PyTorch rust bindings tch-rs. Example of pretrain model. Docker files support the following install libtorch

vaaaaanquish 5 Oct 7, 2022