This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clustering.py | |
from sklearn.cluster import DBSCAN | |
def cluster_tickets_advanced(tfidf_matrix, min_samples=5, eps=0.5): | |
dbscan = DBSCAN(eps=eps, min_samples=min_samples, metric='cosine') | |
clusters = dbscan.fit_predict(tfidf_matrix) | |
return clusters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.cluster import KMeans | |
def cluster_tickets(tfidf_matrix, num_clusters=10): | |
kmeans = KMeans(n_clusters=num_clusters, random_state=42) | |
clusters = kmeans.fit_predict(tfidf_matrix) | |
return clusters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from nltk.tokenize import word_tokenize | |
from nltk.corpus import stopwords | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.metrics.pairwise import cosine_similarity | |
# Module 1: Data Processing | |
def preprocess_text(text): | |
stop_words = set(stopwords.words('english')) |
NewerOlder