https://github.com/rayvilaca/vanilla-knn
A simple implementation of the k-nearest neighbors (KNN) algorithm without using external libraries.
https://github.com/rayvilaca/vanilla-knn
euclidean-distances knn-algorithm knn-classification knn-classifier no-libraries python
Last synced: about 1 month ago
JSON representation
A simple implementation of the k-nearest neighbors (KNN) algorithm without using external libraries.
- Host: GitHub
- URL: https://github.com/rayvilaca/vanilla-knn
- Owner: RayVilaca
- Created: 2024-01-25T21:45:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-25T23:33:56.000Z (over 1 year ago)
- Last Synced: 2024-04-26T13:00:33.778Z (about 1 year ago)
- Topics: euclidean-distances, knn-algorithm, knn-classification, knn-classifier, no-libraries, python
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-en.md
Awesome Lists containing this project
README
# vanilla-knn
[](https://badge.fury.io/py/vanilla-knn)
A simple implementation of the k-nearest neighbors (KNN) algorithm without using external libraries.
## Installation
You can install `vanilla-knn` using pip:
```bash
pip install vanilla-knn
```## Usage
```bash
from vanilla_knn.knn import k_neighbors_classifier# Create a KNN model
modelo = k_neighbors_classifier(n_neighbors=3)# Train the model
X_train = [...] # Your training data
y_train = [...] # Your training labels
modelo.fit(X_train, y_train)# Make predictions
X_test = [...] # Your test data
y_pred = modelo.predict(X_test)# Print the predictions
print("Previsões:", y_pred)
```## Contributions
If you want to contribute to the development of this project, feel free to send pull requests or report issues.