Update README.md
#1
by PhaseCEO - opened
README.md
CHANGED
|
@@ -27,6 +27,31 @@ Trained on the [Xerv-AI/netuark-posts-6000](https://huggingface.co/datasets/Xerv
|
|
| 27 |
## Usage
|
| 28 |
```python
|
| 29 |
import joblib
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
```
|
|
|
|
| 27 |
## Usage
|
| 28 |
```python
|
| 29 |
import joblib
|
| 30 |
+
import os
|
| 31 |
+
from huggingface_hub import hf_hub_download
|
| 32 |
+
|
| 33 |
+
# Define the missing custom function required by the unpickler
|
| 34 |
+
def advanced_clean(text):
|
| 35 |
+
return text
|
| 36 |
+
|
| 37 |
+
# Assign it to __main__ to ensure joblib can find it during loading
|
| 38 |
+
import __main__
|
| 39 |
+
__main__.advanced_clean = advanced_clean
|
| 40 |
+
|
| 41 |
+
# Repository and filename
|
| 42 |
+
repo_id = 'Phase-Technologies/netuark-classifier-ensemble'
|
| 43 |
+
filename = 'netuark_ensemble_classifier.joblib'
|
| 44 |
+
|
| 45 |
+
try:
|
| 46 |
+
# Download the file from Hugging Face
|
| 47 |
+
file_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 48 |
+
|
| 49 |
+
# Load the model
|
| 50 |
+
model = joblib.load(file_path)
|
| 51 |
+
prediction = model.predict(["📰 Perplexity's 'Personal Computer' Lets AI Agents Access Your Local Files #slashdot"])
|
| 52 |
+
print(f"Prediction: {prediction}")
|
| 53 |
+
except Exception as e:
|
| 54 |
+
import traceback
|
| 55 |
+
print(f"An error occurred: {e}")
|
| 56 |
+
traceback.print_exc()
|
| 57 |
```
|