sklears_python/
clustering.rs1use numpy::{PyArray1, PyReadonlyArray2};
7use pyo3::prelude::*;
8
9#[pyclass(name = "KMeans")]
11pub struct PyKMeans {
12 n_clusters: usize,
13}
14
15#[pymethods]
16impl PyKMeans {
17 #[new]
18 fn new(n_clusters: usize) -> Self {
19 Self { n_clusters }
20 }
21
22 fn fit(&mut self, _x: PyReadonlyArray2<f64>) -> PyResult<()> {
23 let _clusters = self.n_clusters;
25 Ok(())
26 }
27
28 fn predict(&self, _x: PyReadonlyArray2<f64>, py: Python<'_>) -> PyResult<Py<PyArray1<i32>>> {
29 Ok(PyArray1::from_vec(py, vec![0i32]).unbind())
30 }
31}
32
33#[pyclass(name = "DBSCAN")]
35pub struct PyDBSCAN {
36 eps: f64,
37}
38
39#[pymethods]
40impl PyDBSCAN {
41 #[new]
42 fn new(eps: f64) -> Self {
43 Self { eps }
44 }
45
46 fn fit(&mut self, _x: PyReadonlyArray2<f64>) -> PyResult<()> {
47 let _epsilon = self.eps;
49 Ok(())
50 }
51
52 fn predict(&self, _x: PyReadonlyArray2<f64>, py: Python<'_>) -> PyResult<Py<PyArray1<i32>>> {
53 Ok(PyArray1::from_vec(py, vec![0i32]).unbind())
54 }
55}