Skip to content

Commit 6ebc245

Browse files
committed
Update news section to include set of changes
1 parent 9cdc95c commit 6ebc245

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

algorithms/linfa-clustering/examples/kmeans.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use ndarray_npy::write_npy;
77
use ndarray_rand::rand::SeedableRng;
88
use rand_isaac::Isaac64Rng;
99

10+
use linfa_nn::distance::LInfDist;
11+
1012
// A routine K-means task: build a synthetic dataset, fit the algorithm on it
1113
// and save both training data and predictions to disk.
1214
fn main() {
@@ -20,7 +22,7 @@ fn main() {
2022

2123
// Configure our training algorithm
2224
let n_clusters = expected_centroids.len_of(Axis(0));
23-
let model = KMeans::params_with_rng(n_clusters, rng)
25+
let model = KMeans::params_with(n_clusters, rng, LInfDist)
2426
.max_n_iterations(200)
2527
.tolerance(1e-5)
2628
.fit(&dataset)

docs/website/content/news/release_050.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,47 @@ title = "Release 0.5.0"
33
date = "2021-10-20"
44
+++
55

6-
Release 0.5.0
7-
86
Linfa's 0.5.0 release adds initial support for the OPTICS algorithm, multinomials logistic regression, and the family of nearest neighbor algorithms. Furthermore, we have improved documentation and introduced hyperparameter checking to all algorithms.
97

8+
<!-- more -->
9+
10+
## New algorithms
11+
12+
[OPTICS](https://en.wikipedia.org/wiki/OPTICS_algorithm) is an algorithm for finding density-based clusters. It can produce reachability-plots, hierarchical structure of clusters. Analysing data without prior assumption of any distribution is a common use-case. The algorithm is added to `linfa-clustering` and an example can be find at [linfa-clustering/examples/optics.rs](https://github.com/rust-ml/linfa/blob/master/algorithms/linfa-clustering/examples/optics.rs).
13+
14+
Extending logistic regression to the multinomial distribution generalizes it to [multiclass problems](https://en.wikipedia.org/wiki/Multinomial_logistic_regression). This release adds support for multinomial logistic regression to `linfa-logistic`, you can experiment with the example at [linfa-logistic/examples/winequality_multi.rs](https://github.com/rust-ml/linfa/blob/master/algorithms/linfa-logistic/examples/winequality_multi.rs).
15+
16+
Nearest neighbor search finds the set of neighborhood points to a given sample. It appears in numerous fields of applications as a distance metric provider. (e.g. clustering) This release adds a family of nearest neighbor algorithms, namely [Ball tree](https://en.wikipedia.org/wiki/Ball_tree), [K-d tree](https://en.wikipedia.org/wiki/K-d_tree) and naive linear search. You can find an example in the next section.
17+
18+
## Improvements
19+
20+
* use least-square solver from `ndarray-linalg` in `linfa-linear`
21+
* make clustering algorithms generic over distance metrics
22+
* bump `ndarray` to 0.15
23+
* introduce `ParamGuard` trait for explicit and implicit parameter checking (read more in the [CONTRIBUTE.md](https://github.com/rust-ml/linfa/blob/master/CONTRIBUTE.md#parameters-and-checking))
24+
* improve documentation in various places
25+
1026
## Nearest Neighbors
1127

1228
You can now choose from a growing list of NN implementations. The family provides efficient distance metrics to KMeans, DBSCAN etc. The example shows how to use KDTree nearest neighbor to find all the points in a set of observations that are within a certain range of a candidate point.
29+
30+
You can query nearest points explicitly:
31+
1332
```rust
1433
// create a KDTree index consisting of all the points in the observations, using Euclidean distance
15-
let kdtree = CommonNearestNeighbour::KdTree.from_batch(observations, L2Dist).unwrap();
34+
let kdtree = CommonNearestNeighbour::KdTree.from_batch(observations, L2Dist)?;
1635
let candidate = observations.row(2);
17-
let points = kdtree.within_range(candidate.view(), range).unwrap();
36+
let points = kdtree.within_range(candidate.view(), range)?;
1837
```
1938

20-
## Multinomial logistic regression
39+
Or use one of the distance metrics implicitly, here demonstrated for KMeans:
2140

22-
Logistic regression models problems with two possible discrete outcomes. Extending this to the multinomial distribution yields the Multinomial Logistic Regression which can model datasets with an arbitrary number of outcomes.
23-
24-
We will try to model the winequality of 1440 samples, you can find the full example [here](https://github.com/rust-ml/linfa/blob/master/algorithms/linfa-logistic/examples/winequality_multi.rs)
2541
```rust
26-
// fit a Logistic regression model with 150 max iterations
27-
let model = MultiLogisticRegression::default()
28-
.max_iterations(50)
29-
.fit(&train)
30-
.unwrap();
42+
use linfa_nn::distance::LInfDist;
43+
44+
let model = KMeans::params_with(3, rng, LInfDist)
45+
.max_n_iterations(200)
46+
.tolerance(1e-5)
47+
.fit(&dataset)?;
3148
```
49+

0 commit comments

Comments
 (0)