Spaces:
Sleeping
Sleeping
Delete quantum_learning.py
Browse files- quantum_learning.py +0 -23
quantum_learning.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
from sentence_transformers import SentenceTransformer
|
| 2 |
-
from sklearn.cluster import KMeans
|
| 3 |
-
import numpy as np
|
| 4 |
-
|
| 5 |
-
class QuantumLearner:
|
| 6 |
-
def __init__(self):
|
| 7 |
-
self.model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')
|
| 8 |
-
|
| 9 |
-
def analyze_conversations(self):
|
| 10 |
-
# Dohvati neenkriptiranu povijest (samo za analizu)
|
| 11 |
-
history = get_history(limit=1000)
|
| 12 |
-
texts = [decrypt_data(row[2]) + " " + decrypt_data(row[3]) for row in history]
|
| 13 |
-
|
| 14 |
-
# Klasteriranje tema
|
| 15 |
-
embeddings = self.model.encode(texts)
|
| 16 |
-
kmeans = KMeans(n_clusters=3).fit(embeddings)
|
| 17 |
-
|
| 18 |
-
# Pronađi najčešće teme
|
| 19 |
-
topics = {}
|
| 20 |
-
for label, text in zip(kmeans.labels_, texts):
|
| 21 |
-
topics[label] = topics.get(label, []) + [text]
|
| 22 |
-
|
| 23 |
-
return {k: v[:3] for k, v in topics.items()} # Vrati 3 reprezentativna primjera po temi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|