Skip to content

Commit

Permalink
Sweet
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollopy-tulane committed Apr 30, 2024
1 parent 159d632 commit d5bb5dd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nlp/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def index():
input_field = form.input_field.data
model_choice = form.model_choice.data
prediction = None
proba = None # Initialize proba variable
proba = None
if model_choice == 'bnb':

model = bnb
Expand All @@ -36,32 +36,32 @@ def index():
else:
prediction = "LOSS"
proba = 1 - positive_proba
prediction = None
proba = None


elif model_choice == 'lr':

model = lr
text = process_text(input_field)
text = lr_vectorizer.transform([text])
probas = lr.predict_proba(text)
positive_proba = probas[:, 1]
prediction = None

if positive_proba > 0.5:
prediction == "WIN"
proba = positive_proba
else:
prediction == "LOSS"
proba = 1 - positive_proba
prediction = None
proba = None

elif model_choice == 'cnn':

# For CNN, assuming preprocessing is handled differently or is built-in
model_path = '/Users/jackiecollopy/Downloads/project-reddit/nlp/cnn_model.h5'
model = load_model(model_path, compile=False)
text = basic_process(input_field)
text = cnn_process(text)
probas = model.predict(text)
positive_proba = probas[:, 1]
prediction = None

if positive_proba > 0.5:
prediction == "WIN"
Expand Down

0 comments on commit d5bb5dd

Please sign in to comment.