Skip to content

Commit 161d249

Browse files
authored
Release 0.3 (#235)
1 parent aab3817 commit 161d249

30 files changed

+131
-101
lines changed

.github/CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ Take a look to the conventions established by existing code:
2626
* Every module should provide comprehensive tests at the end, in its `mod tests {}` sub-module. These tests can be flagged or not with configuration flags to allow WebAssembly target.
2727
* Run `cargo doc --no-deps --open` and read the generated documentation in the browser to be sure that your changes reflects in the documentation and new code is documented.
2828

29+
#### digging deeper
30+
* a nice overview of the codebase is given by [static analyzer](https://mozilla.github.io/rust-code-analysis/metrics.html):
31+
```
32+
$ cargo install rust-code-analysis-cli
33+
// print metrics for every module
34+
$ rust-code-analysis-cli -m -O json -o . -p src/ --pr
35+
// print full AST for a module
36+
$ rust-code-analysis-cli -p src/algorithm/neighbour/fastpair.rs --ls 22 --le 213 -d > ast.txt
37+
```
38+
* find more information about what happens in your binary with [`twiggy`](https://rustwasm.github.io/twiggy/install.html). This need a compiled binary so create a brief `main {}` function using `smartcore` and then point `twiggy` to that file.
39+
2940
## Issue Report Process
3041

3142
1. Go to the project's issues.

.github/DEVELOPERS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Smartcore: Introduction to modules
1+
# smartcore: Introduction to modules
2+
3+
Important source of information:
4+
* [Rust API guidelines](https://rust-lang.github.io/api-guidelines/about.html)
25

36
## Walkthrough: traits system and basic structures
47

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ src.dot
2626
out.svg
2727

2828
FlameGraph/
29-
out.stacks
29+
out.stacks
30+
*.json
31+
*.txt

CHANGELOG.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [0.3.0] - 2022-11-09
88

99
## Added
10-
- Seeds to multiple algorithims that depend on random number generation.
11-
- Added feature `js` to use WASM in browser
12-
- Drop `nalgebra-bindings` feature
13-
- Complete refactoring with *extensive API changes* that includes:
10+
- WARNING: Breaking changes!
11+
- Complete refactoring with **extensive API changes** that includes:
1412
* moving to a new traits system, less structs more traits
1513
* adapting all the modules to the new traits system
16-
* moving towards Rust 2021, in particular the use of `dyn` and `as_ref`
17-
* reorganization of the code base, trying to eliminate duplicates
14+
* moving to Rust 2021, use of object-safe traits and `as_ref`
15+
* reorganization of the code base, eliminate duplicates
16+
- implements `readers` (needs "serde" feature) for read/write CSV file, extendible to other formats
17+
- default feature is now Wasm-/Wasi-first
1818

19-
## BREAKING CHANGE
20-
- Added a new parameter to `train_test_split` to define the seed.
19+
## Changed
20+
- WARNING: Breaking changes!
21+
- Seeds to multiple algorithims that depend on random number generation
22+
- Added a new parameter to `train_test_split` to define the seed
23+
- changed use of "serde" feature
24+
25+
## Dropped
26+
- WARNING: Breaking changes!
27+
- Drop `nalgebra-bindings` feature, only `ndarray` as supported library
2128

22-
## [0.2.1] - 2022-05-10
29+
## [0.2.1] - 2021-05-10
2330

2431
## Added
2532
- L2 regularization penalty to the Logistic Regression

Cargo.toml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
[package]
22
name = "smartcore"
3-
description = "The most advanced machine learning library in rust."
3+
description = "Machine Learning in Rust."
44
homepage = "https://smartcorelib.org"
5-
version = "0.4.0"
6-
authors = ["SmartCore Developers"]
5+
version = "0.3.0"
6+
authors = ["smartcore Developers"]
77
edition = "2021"
88
license = "Apache-2.0"
99
documentation = "https://docs.rs/smartcore"
1010
repository = "https://github.com/smartcorelib/smartcore"
1111
readme = "README.md"
1212
keywords = ["machine-learning", "statistical", "ai", "optimization", "linear-algebra"]
1313
categories = ["science"]
14+
exclude = [
15+
".github",
16+
".gitignore",
17+
"smartcore.iml",
18+
"smartcore.svg",
19+
"tests/"
20+
]
1421

1522
[dependencies]
1623
approx = "0.5.1"
@@ -19,32 +26,31 @@ ndarray = { version = "0.15", optional = true }
1926
num-traits = "0.2.12"
2027
num = "0.4"
2128
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
29+
getrandom = "*"
2230
rand_distr = { version = "0.4", optional = true }
2331
serde = { version = "1", features = ["derive"], optional = true }
2432

2533
[features]
26-
default = ["serde", "datasets"]
34+
default = []
2735
serde = ["dep:serde"]
2836
ndarray-bindings = ["dep:ndarray"]
29-
datasets = ["dep:rand_distr", "std"]
30-
std = ["rand/std_rng", "rand/std"]
31-
# wasm32 only
37+
datasets = ["dep:rand_distr", "std_rand", "serde"]
38+
std_rand = ["rand/std_rng", "rand/std"]
39+
# used by wasm32-unknown-unknown for in-browser usage
3240
js = ["getrandom/js"]
3341

3442
[target.'cfg(target_arch = "wasm32")'.dependencies]
3543
getrandom = { version = "0.2", optional = true }
3644

45+
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
46+
wasm-bindgen-test = "0.3"
47+
3748
[dev-dependencies]
3849
itertools = "*"
39-
criterion = { version = "0.4", default-features = false }
4050
serde_json = "1.0"
4151
bincode = "1.3.1"
4252

43-
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
44-
wasm-bindgen-test = "0.3"
45-
4653
[workspace]
47-
resolver = "2"
4854

4955
[profile.test]
5056
debug = 1

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2019-present at SmartCore developers (smartcorelib.org)
189+
Copyright 2019-present at smartcore developers (smartcorelib.org)
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<a href="https://smartcorelib.org">
3-
<img src="smartcore.svg" width="450" alt="SmartCore">
3+
<img src="smartcore.svg" width="450" alt="smartcore">
44
</a>
55
</p>
66
<p align = "center">
@@ -18,4 +18,4 @@
1818
-----
1919
[![CI](https://github.com/smartcorelib/smartcore/actions/workflows/ci.yml/badge.svg)](https://github.com/smartcorelib/smartcore/actions/workflows/ci.yml)
2020

21-
To start getting familiar with the new Smartcore v0.5 API, there is now available a [**Jupyter Notebook environment repository**](https://github.com/smartcorelib/smartcore-jupyter). Please see instructions there, contributions welcome see [CONTRIBUTING](.github/CONTRIBUTING.md).
21+
To start getting familiar with the new smartcore v0.5 API, there is now available a [**Jupyter Notebook environment repository**](https://github.com/smartcorelib/smartcore-jupyter). Please see instructions there, contributions welcome see [CONTRIBUTING](.github/CONTRIBUTING.md).

smartcore.svg

Lines changed: 1 addition & 1 deletion
Loading

src/algorithm/neighbour/cover_tree.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct Node {
6464
max_dist: f64,
6565
parent_dist: f64,
6666
children: Vec<Node>,
67-
scale: i64,
67+
_scale: i64,
6868
}
6969

7070
#[derive(Debug)]
@@ -84,7 +84,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
8484
max_dist: 0f64,
8585
parent_dist: 0f64,
8686
children: Vec::new(),
87-
scale: 0,
87+
_scale: 0,
8888
};
8989
let mut tree = CoverTree {
9090
base,
@@ -245,7 +245,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
245245
max_dist: 0f64,
246246
parent_dist: 0f64,
247247
children: Vec::new(),
248-
scale: 100,
248+
_scale: 100,
249249
}
250250
}
251251

@@ -306,7 +306,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
306306
max_dist: 0f64,
307307
parent_dist: 0f64,
308308
children,
309-
scale: 100,
309+
_scale: 100,
310310
}
311311
} else {
312312
let mut far: Vec<DistanceSet> = Vec::new();
@@ -375,7 +375,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
375375
max_dist: self.max(consumed_set),
376376
parent_dist: 0f64,
377377
children,
378-
scale: (top_scale - max_scale),
378+
_scale: (top_scale - max_scale),
379379
}
380380
}
381381
}

src/cluster/kmeans.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! these re-calculated centroids becoming the new centers of their respective clusters. Next all instances of the training set are re-assigned to their closest cluster again.
1212
//! This iterative process continues until convergence is achieved and the clusters are considered settled.
1313
//!
14-
//! Initial choice of K data points is very important and has big effect on performance of the algorithm. SmartCore uses k-means++ algorithm to initialize cluster centers.
14+
//! Initial choice of K data points is very important and has big effect on performance of the algorithm. `smartcore` uses k-means++ algorithm to initialize cluster centers.
1515
//!
1616
//! Example:
1717
//!
@@ -74,7 +74,7 @@ pub struct KMeans<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>> {
7474
k: usize,
7575
_y: Vec<usize>,
7676
size: Vec<usize>,
77-
distortion: f64,
77+
_distortion: f64,
7878
centroids: Vec<Vec<f64>>,
7979
_phantom_tx: PhantomData<TX>,
8080
_phantom_ty: PhantomData<TY>,
@@ -313,7 +313,7 @@ impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>> KMeans<TX, TY, X, Y>
313313
k: parameters.k,
314314
_y: y,
315315
size,
316-
distortion,
316+
_distortion: distortion,
317317
centroids,
318318
_phantom_tx: PhantomData,
319319
_phantom_ty: PhantomData,
@@ -470,7 +470,7 @@ mod tests {
470470
wasm_bindgen_test::wasm_bindgen_test
471471
)]
472472
#[test]
473-
fn fit_predict_iris() {
473+
fn fit_predict() {
474474
let x = DenseMatrix::from_2d_array(&[
475475
&[5.1, 3.5, 1.4, 0.2],
476476
&[4.9, 3.0, 1.4, 0.2],

0 commit comments

Comments
 (0)