Skip to content

Commit

Permalink
Update readmes, changelog
Browse files Browse the repository at this point in the history
Update `Cargo.toml`
  • Loading branch information
shadeMe committed Apr 2, 2023
1 parent 22302fd commit 59d8611
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 35 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[![Latest Version]][crates.io]
![MIT]

# liblinear-rs

This is the official repository for the [liblinear](crates/liblinear/) Rust library and its support crates.

[latest version]: https://img.shields.io/crates/v/liblinear.svg
[crates.io]: https://crates.io/crates/liblinear
[mit]: https://img.shields.io/badge/license-MIT-blue.svg
10 changes: 9 additions & 1 deletion crates/liblinear-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
[package]
name = "liblinear-macros"
version = "0.1.0"
authors = ["Madeesh Kannan"]
edition = "2021"

readme = "README.md"
description = "Macros for the `liblinear` crate"
repository = "https://github.com/shadeMe/liblinear-rs"
keywords = ["machine-learning", "statistics", "svm", "linear-model"]
categories = ["api-bindings", "science", "simulation"]
license = "MIT"

[lib]
proc-macro = true

[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full"] }
syn = { version = "2.0", features = ["full"] }
2 changes: 0 additions & 2 deletions crates/liblinear-macros/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Latest Version]][crates.io]
[![deps.svg]][deps]
![MIT]

# liblinear-macros
Expand All @@ -13,4 +12,3 @@ Macros for the [liblinear](https://github.com/shadeMe/liblinear-rs) Rust library
[latest version]: https://img.shields.io/crates/v/liblinear-macros.svg
[crates.io]: https://crates.io/crates/liblinear-macros
[mit]: https://img.shields.io/badge/license-MIT-blue.svg
[deps.svg]: https://deps.rs/repo/github/shademe/liblinear-rs/status.svg
38 changes: 38 additions & 0 deletions crates/liblinear/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Changelog

## 2.0.0

### Breaking

- Rewrite public API to utilize compile-time validation of models and parameters.
- Replace `failure` with `thiserror`.
- Update LIBLINEAR to `v246`.
- Expose one-class SVM solver.
- Reorganize as `cargo` workspace.
- Add `liblinear-macros` crate.

### Non-breaking

- Use `-O2` optimizations when compiling LIBLINEAR.

## 1.0.0

### Breaking

- Update LIBLINEAR to `v230`.
- `ParameterError` - Add variant `IllegalArgument`.
- `LibLinearCrossValidator` - Change `find_optimal_constraints_violation_cost` to `find_optimal_constraints_violation_cost_and_loss_sensitivity` signature.

### Non-breaking

- Fix build failures on macOS by automatically selecting the C++ standard library when compiling LIBLINEAR.
- Update dependencies.

## 0.1.1

- Added readme.
- Minor documentation fixes.

## 0.1.0

- Initial release.
55 changes: 23 additions & 32 deletions crates/liblinear/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,45 @@

# liblinear

Rust bindings for the [liblinear](https://github.com/cjlin1/liblinear) C/C++ library.
Rust bindings for the [LIBLINEAR](https://github.com/cjlin1/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.

```rust
use liblinear::*;
use liblinear::{
Model,
Parameters,
TrainingInput,
PredictionInput,
solver::L2R_LR,
model::traits::*,
parameter::traits::*,
solver::traits::*,
};

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)],
];
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::default();
model_builder
.problem()
.input_data(util::TrainingInput::from_sparse_features(y, x).unwrap())
.bias(0f64);
model_builder
.parameters()
.solver_type(SolverType::L2R_LR)
let mut params = Parameters::<L2R_LR>::default();
params
.bias(0f64)
.stopping_tolerance(0.1f64)
.constraints_violation_cost(0.1f64)
.regression_loss_sensitivity(1f64);
.constraints_violation_cost(0.1f64);

let model = model_builder.build_model().unwrap();
assert_eq!(model.num_classes(), 2);
let model = Model::train(&TrainingInput::from_sparse_features(y, x).unwrap(), &params).unwrap();

let predicted_class = model
.predict(util::PredictionInput::from_sparse_features(vec![(1u32, 2.2f64)]).unwrap())
.predict(&PredictionInput::from_sparse_features(vec![(3u32, 9.9f64)]).unwrap())
.unwrap();
println!(predicted_class);
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.
Refer to the [API docs][docs.rs] for more information.

[latest version]: https://img.shields.io/crates/v/liblinear.svg
[crates.io]: https://crates.io/crates/liblinear
Expand Down

0 comments on commit 59d8611

Please sign in to comment.