6 个版本

0.3.2 2023 年 5 月 1 日
0.3.1 2023 年 3 月 20 日
0.3.0 2022 年 11 月 9 日
0.2.1 2022 年 5 月 9 日
0.1.0 2020 年 9 月 26 日

#51 in 机器学习

Download history 785/week @ 2024-03-13 673/week @ 2024-03-20 570/week @ 2024-03-27 552/week @ 2024-04-03 792/week @ 2024-04-10 737/week @ 2024-04-17 1003/week @ 2024-04-24 651/week @ 2024-05-01 471/week @ 2024-05-08 778/week @ 2024-05-15 826/week @ 2024-05-22 879/week @ 2024-05-29 603/week @ 2024-06-05 558/week @ 2024-06-12 630/week @ 2024-06-19 599/week @ 2024-06-26

2,482 每月下载量
14 包中使用 (11 个直接使用)

Apache-2.0

1MB
23K SLoC

smartcore

用户指南 | API | 笔记本


Rust 中的机器学习


CI

为了开始熟悉新的 smartcore v0.3 API,现在有一个可用的 Jupyter Notebook 环境仓库。请参阅那里的说明,欢迎贡献请看 CONTRIBUTING


lib.rs:

smartcore

欢迎使用 smartcore,Rust 中的机器学习!

smartcore 提供了各种分类、回归和聚类算法,包括支持向量机、随机森林、k-means 和 DBSCAN,以及模型选择和模型评估的工具。

smartcore 提供了自己的 traits 系统,扩展了 Rust 标准库,用于处理线性代数和常见计算模型。其 API 使用了易于识别的模式。额外的功能(如对 ndarray 结构的支持)可以通过可选功能获得。

入门

要开始使用 smartcore 最新稳定版本,只需将以下内容添加到您的 Cargo.toml 文件中

[dependencies]
smartcore = "*"

要开始使用带有最新不稳定添加的 smartcore 开发版本

[dependencies]
smartcore = { git = "https://github.com/smartcorelib/smartcore", branch = "development" }

可以添加不同的功能到基础库中,例如添加样本数据集

[dependencies]
smartcore = { git = "https://github.com/smartcorelib/smartcore", features = ["datasets"] }

查看 smartcoreCargo.toml 了解可用功能。

使用 Jupyter

为了快速介绍,Jupyter Notebooks 可在 此处 获取。您可以使用 EVCXR 按照以下 说明 设置本地环境来运行 Rust 笔记本。

第一个例子

例如,您可以使用此代码将一个定义为标准Rust向量的数据集拟合到K近邻分类器

// DenseMatrix definition
use smartcore::linalg::basic::matrix::DenseMatrix;
// KNNClassifier
use smartcore::neighbors::knn_classifier::*;
// Various distance metrics
use smartcore::metrics::distance::*;

// Turn Rust vector-slices with samples into a matrix
let x = DenseMatrix::from_2d_array(&[
   &[1., 2.],
   &[3., 4.],
   &[5., 6.],
   &[7., 8.],
   &[9., 10.]]);
// Our classes are defined as a vector
let y = vec![2, 2, 2, 3, 3];

// Train classifier
let knn = KNNClassifier::fit(&x, &y, Default::default()).unwrap();

// Predict classes
let y_hat = knn.predict(&x).unwrap();

概述

支持算法

所有机器学习算法都被归类到以下广泛类别中

线性代数特质系统

有关smartcore特质系统的介绍,请参阅此笔记本

依赖项

~0.7–1.7MB
~32K SLoC