Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,7 @@ import googlemaps
|
|
11 |
import folium
|
12 |
import torch
|
13 |
import pandas as pd
|
14 |
-
from
|
15 |
-
from tensorflow.keras import layers
|
16 |
from sklearn.ensemble import RandomForestClassifier
|
17 |
from sklearn.naive_bayes import GaussianNB
|
18 |
from sklearn.metrics import accuracy_score
|
@@ -38,15 +37,13 @@ def build_chatbot_model(input_shape, output_shape):
|
|
38 |
model = keras.Sequential()
|
39 |
model.add(layers.Input(shape=(input_shape,)))
|
40 |
model.add(layers.Dense(8, activation='relu'))
|
41 |
-
model.add(layers.Dense(
|
42 |
-
model.add(layers.Dense(output_shape, activation='softmax'))
|
43 |
-
|
44 |
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
|
45 |
return model
|
46 |
|
47 |
# Build and train the chatbot model
|
48 |
chatbot_model = build_chatbot_model(len(training[0]), len(output[0]))
|
49 |
-
chatbot_model.fit(training, output, epochs=100) #
|
50 |
|
51 |
# Hugging Face sentiment and emotion models
|
52 |
tokenizer_sentiment = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
@@ -113,7 +110,7 @@ def load_data():
|
|
113 |
# Replace prognosis values with numerical categories
|
114 |
df.replace({'prognosis': disease_dict}, inplace=True)
|
115 |
|
116 |
-
# Check unique values in prognosis
|
117 |
print("Unique values in prognosis after mapping:", df['prognosis'].unique())
|
118 |
|
119 |
# Ensure prognosis is purely numerical after mapping
|
@@ -314,11 +311,11 @@ def app_function(user_input, location, query, symptoms, history):
|
|
314 |
disease_results = disease_prediction_interface(symptoms)
|
315 |
|
316 |
return (
|
317 |
-
chatbot_history,
|
318 |
-
sentiment_result,
|
319 |
-
emotion_result,
|
320 |
-
suggestions,
|
321 |
-
professionals,
|
322 |
map_html,
|
323 |
disease_results
|
324 |
)
|
|
|
11 |
import folium
|
12 |
import torch
|
13 |
import pandas as pd
|
14 |
+
from sklearn.tree import DecisionTreeClassifier
|
|
|
15 |
from sklearn.ensemble import RandomForestClassifier
|
16 |
from sklearn.naive_bayes import GaussianNB
|
17 |
from sklearn.metrics import accuracy_score
|
|
|
37 |
model = keras.Sequential()
|
38 |
model.add(layers.Input(shape=(input_shape,)))
|
39 |
model.add(layers.Dense(8, activation='relu'))
|
40 |
+
model.add(layers.Dense(len(output_shape), activation='softmax'))
|
|
|
|
|
41 |
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
|
42 |
return model
|
43 |
|
44 |
# Build and train the chatbot model
|
45 |
chatbot_model = build_chatbot_model(len(training[0]), len(output[0]))
|
46 |
+
chatbot_model.fit(training, output, epochs=100) # Ensure training data is prepared accordingly
|
47 |
|
48 |
# Hugging Face sentiment and emotion models
|
49 |
tokenizer_sentiment = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
|
|
110 |
# Replace prognosis values with numerical categories
|
111 |
df.replace({'prognosis': disease_dict}, inplace=True)
|
112 |
|
113 |
+
# Check unique values in prognosis for debugging
|
114 |
print("Unique values in prognosis after mapping:", df['prognosis'].unique())
|
115 |
|
116 |
# Ensure prognosis is purely numerical after mapping
|
|
|
311 |
disease_results = disease_prediction_interface(symptoms)
|
312 |
|
313 |
return (
|
314 |
+
chatbot_history,
|
315 |
+
sentiment_result,
|
316 |
+
emotion_result,
|
317 |
+
suggestions,
|
318 |
+
professionals,
|
319 |
map_html,
|
320 |
disease_results
|
321 |
)
|