Upload configuration_knn.py with huggingface_hub
Browse files- configuration_knn.py +35 -0
configuration_knn.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig
|
| 2 |
+
from typing import List, Optional
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class KNNConfig(PretrainedConfig):
|
| 6 |
+
"""
|
| 7 |
+
Minimal Transformers-style config for a scikit-learn KNN model.
|
| 8 |
+
|
| 9 |
+
This stores only metadata needed to describe the model on the Hub.
|
| 10 |
+
|
| 11 |
+
For ensemble models (7T-21T, Synthetic), is_ensemble=True and
|
| 12 |
+
ensemble_members lists the sub-model filenames.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
model_type = "knn"
|
| 16 |
+
|
| 17 |
+
def __init__(
|
| 18 |
+
self,
|
| 19 |
+
n_neighbors: int = 3,
|
| 20 |
+
metric: str = "euclidean",
|
| 21 |
+
feature_names: Optional[List[str]] = None,
|
| 22 |
+
is_ensemble: bool = False,
|
| 23 |
+
ensemble_members: Optional[List[str]] = None,
|
| 24 |
+
data_source: Optional[str] = None,
|
| 25 |
+
training_version: Optional[str] = None,
|
| 26 |
+
**kwargs,
|
| 27 |
+
):
|
| 28 |
+
self.n_neighbors = n_neighbors
|
| 29 |
+
self.metric = metric
|
| 30 |
+
self.feature_names = feature_names or []
|
| 31 |
+
self.is_ensemble = is_ensemble
|
| 32 |
+
self.ensemble_members = ensemble_members or []
|
| 33 |
+
self.data_source = data_source
|
| 34 |
+
self.training_version = training_version
|
| 35 |
+
super().__init__(**kwargs)
|