Crates.io | dendritic-knn |
lib.rs | dendritic-knn |
version | 1.5.0 |
source | src |
created_at | 2024-10-28 13:27:45.604448 |
updated_at | 2024-11-01 19:43:29.038574 |
description | Package for algorithms related to K Nearest Neighbors |
homepage | |
repository | |
max_upload_size | |
id | 1425619 |
size | 20,666 |
This crate contains functionality for performing K nearest neighbors for classification and regression. Package also contains all distance metrics that can be used across dendritic.
The dendritic project is a toy machine learning library built for learning and research purposes. It is not advised by the maintainer to use this library as a production ready machine learning library. This is a project that is still very much a work in progress.
This is an example of using the KNN classifier
use dendritic_datasets::iris::*;
use dendritic_knn::knn::*;
use dendritic_knn::distance::*;
fn main() {
// Load iris flowers dataset
let (x, y) = load_iris("../dendritic-datasets/data/iris.parquet").unwrap();
let (x_train, x_test) = x.split(0, 0.80).unwrap(); // split rows with 80/20 split
let (y_train, y_test) = y.split(0, 0.80).unwrap();
let clf = KNN::fit(
&x_train,
&y_train,
4,
euclidean
).unwrap();
let predictions = clf.predict(&x_test);
println!("Actual: {:?}", predictions.values());
println!("Prediction: {:?}", y_test.values());
}