Spaces:
Running
Running
Add new code to app.py that helps with feature matching.
Browse files
app.py
CHANGED
@@ -35,6 +35,14 @@ def vectorize_text(text):
|
|
35 |
text = vectorizer.fit_transform([text])
|
36 |
return text
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
def predict(text):
|
39 |
text = vectorize_text(text)
|
40 |
prediction = model.predict(text)
|
|
|
35 |
text = vectorizer.fit_transform([text])
|
36 |
return text
|
37 |
|
38 |
+
# Valid input for the model so number of features match
|
39 |
+
def create_valid_input(text):
|
40 |
+
text = vectorize_text(text)
|
41 |
+
text = text.toarray()
|
42 |
+
text = text.reshape(1, -1)
|
43 |
+
return text
|
44 |
+
|
45 |
+
# Prediction function
|
46 |
def predict(text):
|
47 |
text = vectorize_text(text)
|
48 |
prediction = model.predict(text)
|