Satyam0077 commited on
Commit
8e687b3
·
verified ·
1 Parent(s): ddc1074

Update src/inference.py

Browse files
Files changed (1) hide show
  1. src/inference.py +9 -7
src/inference.py CHANGED
@@ -1,17 +1,18 @@
1
  import os
2
- from src.preprocessing import clean_text
3
- from src.features import create_features
4
- from src.model import load_model
5
- from src.entity_extraction import extract_entities
6
  import numpy as np
7
  import joblib
8
  import scipy.sparse
9
  from textblob import TextBlob
10
 
11
- # Correct path to model files
12
- BASE_PATH = os.path.join(os.path.dirname(__file__), 'models')
 
 
 
 
 
13
 
14
- # Load models from correct location
15
  model_issue = load_model(os.path.join(BASE_PATH, 'model_issue_type.pkl'))
16
  model_urgency = load_model(os.path.join(BASE_PATH, 'model_urgency_level.pkl'))
17
  tfidf = joblib.load(os.path.join(BASE_PATH, 'tfidf.pkl'))
@@ -22,6 +23,7 @@ def predict_ticket(ticket_text):
22
  ticket_length = len(clean.split())
23
  sentiment = TextBlob(clean).sentiment.polarity
24
 
 
25
  X_features = scipy.sparse.hstack([
26
  X_tfidf,
27
  np.array([[ticket_length]]),
 
1
  import os
 
 
 
 
2
  import numpy as np
3
  import joblib
4
  import scipy.sparse
5
  from textblob import TextBlob
6
 
7
+ from src.preprocessing import clean_text
8
+ from src.features import create_features
9
+ from src.model import load_model
10
+ from src.entity_extraction import extract_entities
11
+
12
+ # Set BASE_PATH to the absolute path of the models directory relative to this file
13
+ BASE_PATH = os.path.join(os.path.dirname(__file__), '..', 'models')
14
 
15
+ # Load models & tfidf vectorizer from models directory
16
  model_issue = load_model(os.path.join(BASE_PATH, 'model_issue_type.pkl'))
17
  model_urgency = load_model(os.path.join(BASE_PATH, 'model_urgency_level.pkl'))
18
  tfidf = joblib.load(os.path.join(BASE_PATH, 'tfidf.pkl'))
 
23
  ticket_length = len(clean.split())
24
  sentiment = TextBlob(clean).sentiment.polarity
25
 
26
+ # Combine features: tfidf + ticket length + sentiment
27
  X_features = scipy.sparse.hstack([
28
  X_tfidf,
29
  np.array([[ticket_length]]),