Spaces:
Runtime error
Runtime error
Vertical line added as divider
Browse files
app.py
CHANGED
@@ -55,27 +55,31 @@ def resume():
|
|
55 |
|
56 |
# Main function to run the app
|
57 |
def main():
|
58 |
-
st.sidebar.title("
|
59 |
page_options = ["Classification", "Regressor", "NLP", "Image", "Voice", "Video", "LLMs"]
|
60 |
-
choice = st.sidebar.radio("
|
61 |
|
62 |
if choice == "Classification":
|
63 |
train, test = st.tabs(['Train','Test'])
|
64 |
|
65 |
with train:
|
66 |
st.title("Classification / Train data")
|
67 |
-
spectra = st.file_uploader("Upload file", type={"csv", "txt"})
|
68 |
|
69 |
if spectra is not None:
|
70 |
spectra_df = pd.read_csv(spectra)
|
71 |
|
72 |
st.write(spectra_df.head(5))
|
73 |
# st.write("Headers", spectra_df.columns.tolist())
|
74 |
-
st.write("Total Rows", spectra_df.shape[0])
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
option = st.text_input("Enter your text here:")
|
77 |
if option:
|
78 |
-
st.write("You have selected output column
|
79 |
|
80 |
y = spectra_df[option]
|
81 |
X= spectra_df.drop(option, axis=1)
|
@@ -85,13 +89,15 @@ def main():
|
|
85 |
|
86 |
# Add content to col1
|
87 |
with col1:
|
88 |
-
st.
|
89 |
st.write(X.head(5))
|
90 |
|
91 |
# Add content to col2
|
92 |
with col2:
|
93 |
-
st.
|
94 |
st.write(y.head(5))
|
|
|
|
|
95 |
|
96 |
list_of_classifier_models = [
|
97 |
"Naive Bayes Classifier",
|
@@ -113,11 +119,11 @@ def main():
|
|
113 |
"K-Means Clustering": ["n_clusters", "init"]
|
114 |
}
|
115 |
|
116 |
-
selected_models = st.multiselect("Select Models",list_of_classifier_models)
|
117 |
|
118 |
# Execute further code based on selected models
|
119 |
if selected_models:
|
120 |
-
st.write("Selected Models:", selected_models)
|
121 |
|
122 |
# Toggle to add hyperparameters
|
123 |
add_hyperparameters = st.toggle("Add Hyperparameters")
|
@@ -213,7 +219,7 @@ def main():
|
|
213 |
naive_bayes_model = clf.naive_bayes_classifier(model_hyperparameters)
|
214 |
naive_bayes_accuracy = clf.evaluate_model(naive_bayes_model)
|
215 |
# naive_bayes_classification_report = clf.evaluate_classification_report(naive_bayes_model)
|
216 |
-
st.write("Naive Bayes Accuracy:", naive_bayes_accuracy)
|
217 |
accuracy_dict[models] = naive_bayes_accuracy
|
218 |
# st.write("Naive Bayes Classification Report:", pd.DataFrame(naive_bayes_classification_report))
|
219 |
if models == "Logistic Regression":
|
@@ -221,7 +227,7 @@ def main():
|
|
221 |
logistic_regression_model = clf.logistic_regression(model_hyperparameters)
|
222 |
logistic_regression_accuracy = clf.evaluate_model(logistic_regression_model)
|
223 |
# logistic_regression_classification_report = clf.evaluate_classification_report(logistic_regression_model)
|
224 |
-
st.write("Logistic Regression Accuracy:", logistic_regression_accuracy)
|
225 |
accuracy_dict[models] = logistic_regression_accuracy
|
226 |
# st.write("Logistic Regression Classification Report:", pd.DataFrame(logistic_regression_classification_report))
|
227 |
|
@@ -229,7 +235,7 @@ def main():
|
|
229 |
decision_tree_model = clf.decision_tree(model_hyperparameters)
|
230 |
decision_tree_accuracy = clf.evaluate_model(decision_tree_model)
|
231 |
# decision_tree_classification_report = clf.evaluate_classification_report(decision_tree_model)
|
232 |
-
st.write("Decision Tree Accuracy:", decision_tree_accuracy)
|
233 |
accuracy_dict[models] = decision_tree_accuracy
|
234 |
# st.write("Decision Tree Classification Report:", pd.DataFrame(decision_tree_classification_report))
|
235 |
|
@@ -238,7 +244,7 @@ def main():
|
|
238 |
random_forests_accuracy = clf.evaluate_model(random_forests_model)
|
239 |
accuracy_dict[models] = random_forests_accuracy
|
240 |
# random_forest_classification_report = clf.evaluate_classification_report(random_forests_model)
|
241 |
-
st.write("Random Forests Accuracy:", random_forests_accuracy)
|
242 |
# st.write("Random Forests Classification Report:", pd.DataFrame(random_forest_classification_report))
|
243 |
|
244 |
if models == "SVM":
|
@@ -246,7 +252,7 @@ def main():
|
|
246 |
svm_accuracy = clf.evaluate_model(svm_model)
|
247 |
accuracy_dict[models] = svm_accuracy
|
248 |
# svm_classification_report = clf.evaluate_classification_report(svm_model)
|
249 |
-
st.write("Support Vector Machines Accuracy:", svm_accuracy)
|
250 |
# st.write("Support Vector Machines Classification Report:", pd.DataFrame(svm_classification_report))
|
251 |
|
252 |
|
@@ -255,7 +261,7 @@ def main():
|
|
255 |
knn_accuracy = clf.evaluate_model(knn_model)
|
256 |
accuracy_dict[models] = knn_accuracy
|
257 |
# knn_classification_report = clf.evaluate_classification_report(knn_model)
|
258 |
-
st.write("K-Nearest Neighbors Accuracy:", knn_accuracy)
|
259 |
# st.write("K-Nearest Neighbors Classification Report:", pd.DataFrame(knn_classification_report))
|
260 |
|
261 |
if models == "K- Means Clustering":
|
@@ -263,10 +269,11 @@ def main():
|
|
263 |
kmeans_accuracy = clf.evaluate_model(kmeans_model)
|
264 |
accuracy_dict[models] = kmeans_accuracy
|
265 |
# knn_classification_report = clf.evaluate_classification_report(knn_model)
|
266 |
-
st.write("K-Nearest Neighbors Accuracy:", kmeans_accuracy)
|
267 |
# st.write("K-Nearest Neighbors Classification Report:", pd.DataFrame(knn_classification_report))
|
268 |
|
269 |
-
st.
|
|
|
270 |
max_key = ''
|
271 |
max_value = 0
|
272 |
for i in accuracy_dict:
|
@@ -274,10 +281,12 @@ def main():
|
|
274 |
max_key = i
|
275 |
max_value = accuracy_dict[i]
|
276 |
|
277 |
-
|
278 |
-
|
|
|
279 |
|
280 |
-
with test:
|
|
|
281 |
spectra_1 = st.file_uploader("Upload file test the model", type={"csv", "txt"})
|
282 |
|
283 |
if spectra_1 is not None:
|
@@ -285,7 +294,7 @@ def main():
|
|
285 |
Actual = spectra_df1['Disease']
|
286 |
spectra_df1 = spectra_df1.drop(columns=['Disease'])
|
287 |
st.write(spectra_df1.head(5))
|
288 |
-
|
289 |
|
290 |
model_dict ={
|
291 |
"Naive Bayes Classifier":'GaussianNB()',
|
@@ -338,6 +347,8 @@ def main():
|
|
338 |
kmeans_model =kmeans_model.predict(X)
|
339 |
st.write("K-Means Clustering Model:", kmeans_model)
|
340 |
|
|
|
|
|
341 |
data_frame = pd.DataFrame(X).to_csv().encode('utf-8')
|
342 |
st.download_button(
|
343 |
label="Download data as CSV",
|
@@ -346,6 +357,8 @@ def main():
|
|
346 |
mime='text/csv',
|
347 |
)
|
348 |
|
|
|
|
|
349 |
elif choice == "Regressor":
|
350 |
regressor()
|
351 |
elif choice == "NLP":
|
|
|
55 |
|
56 |
# Main function to run the app
|
57 |
def main():
|
58 |
+
st.sidebar.title("Deep Learning/ Data Science/ AI Models")
|
59 |
page_options = ["Classification", "Regressor", "NLP", "Image", "Voice", "Video", "LLMs"]
|
60 |
+
choice = st.sidebar.radio("Select", page_options)
|
61 |
|
62 |
if choice == "Classification":
|
63 |
train, test = st.tabs(['Train','Test'])
|
64 |
|
65 |
with train:
|
66 |
st.title("Classification / Train data")
|
67 |
+
spectra = st.file_uploader("**Upload file**", type={"csv", "txt"})
|
68 |
|
69 |
if spectra is not None:
|
70 |
spectra_df = pd.read_csv(spectra)
|
71 |
|
72 |
st.write(spectra_df.head(5))
|
73 |
# st.write("Headers", spectra_df.columns.tolist())
|
74 |
+
st.write("**Total Rows**", spectra_df.shape[0])
|
75 |
+
|
76 |
+
st.divider()
|
77 |
+
|
78 |
+
option = st.text_input("**Select Output Column**:")
|
79 |
+
st.divider()
|
80 |
|
|
|
81 |
if option:
|
82 |
+
st.write("**You have selected output column**: ", option)
|
83 |
|
84 |
y = spectra_df[option]
|
85 |
X= spectra_df.drop(option, axis=1)
|
|
|
89 |
|
90 |
# Add content to col1
|
91 |
with col1:
|
92 |
+
st.write("Train data excluding output")
|
93 |
st.write(X.head(5))
|
94 |
|
95 |
# Add content to col2
|
96 |
with col2:
|
97 |
+
st.write("Output")
|
98 |
st.write(y.head(5))
|
99 |
+
|
100 |
+
st.divider()
|
101 |
|
102 |
list_of_classifier_models = [
|
103 |
"Naive Bayes Classifier",
|
|
|
119 |
"K-Means Clustering": ["n_clusters", "init"]
|
120 |
}
|
121 |
|
122 |
+
selected_models = st.multiselect("**Select Models**:",list_of_classifier_models)
|
123 |
|
124 |
# Execute further code based on selected models
|
125 |
if selected_models:
|
126 |
+
# st.write("Selected Models:", selected_models)
|
127 |
|
128 |
# Toggle to add hyperparameters
|
129 |
add_hyperparameters = st.toggle("Add Hyperparameters")
|
|
|
219 |
naive_bayes_model = clf.naive_bayes_classifier(model_hyperparameters)
|
220 |
naive_bayes_accuracy = clf.evaluate_model(naive_bayes_model)
|
221 |
# naive_bayes_classification_report = clf.evaluate_classification_report(naive_bayes_model)
|
222 |
+
# st.write("Naive Bayes Accuracy:", naive_bayes_accuracy)
|
223 |
accuracy_dict[models] = naive_bayes_accuracy
|
224 |
# st.write("Naive Bayes Classification Report:", pd.DataFrame(naive_bayes_classification_report))
|
225 |
if models == "Logistic Regression":
|
|
|
227 |
logistic_regression_model = clf.logistic_regression(model_hyperparameters)
|
228 |
logistic_regression_accuracy = clf.evaluate_model(logistic_regression_model)
|
229 |
# logistic_regression_classification_report = clf.evaluate_classification_report(logistic_regression_model)
|
230 |
+
# st.write("Logistic Regression Accuracy:", logistic_regression_accuracy)
|
231 |
accuracy_dict[models] = logistic_regression_accuracy
|
232 |
# st.write("Logistic Regression Classification Report:", pd.DataFrame(logistic_regression_classification_report))
|
233 |
|
|
|
235 |
decision_tree_model = clf.decision_tree(model_hyperparameters)
|
236 |
decision_tree_accuracy = clf.evaluate_model(decision_tree_model)
|
237 |
# decision_tree_classification_report = clf.evaluate_classification_report(decision_tree_model)
|
238 |
+
# st.write("Decision Tree Accuracy:", decision_tree_accuracy)
|
239 |
accuracy_dict[models] = decision_tree_accuracy
|
240 |
# st.write("Decision Tree Classification Report:", pd.DataFrame(decision_tree_classification_report))
|
241 |
|
|
|
244 |
random_forests_accuracy = clf.evaluate_model(random_forests_model)
|
245 |
accuracy_dict[models] = random_forests_accuracy
|
246 |
# random_forest_classification_report = clf.evaluate_classification_report(random_forests_model)
|
247 |
+
# st.write("Random Forests Accuracy:", random_forests_accuracy)
|
248 |
# st.write("Random Forests Classification Report:", pd.DataFrame(random_forest_classification_report))
|
249 |
|
250 |
if models == "SVM":
|
|
|
252 |
svm_accuracy = clf.evaluate_model(svm_model)
|
253 |
accuracy_dict[models] = svm_accuracy
|
254 |
# svm_classification_report = clf.evaluate_classification_report(svm_model)
|
255 |
+
# st.write("Support Vector Machines Accuracy:", svm_accuracy)
|
256 |
# st.write("Support Vector Machines Classification Report:", pd.DataFrame(svm_classification_report))
|
257 |
|
258 |
|
|
|
261 |
knn_accuracy = clf.evaluate_model(knn_model)
|
262 |
accuracy_dict[models] = knn_accuracy
|
263 |
# knn_classification_report = clf.evaluate_classification_report(knn_model)
|
264 |
+
# st.write("K-Nearest Neighbors Accuracy:", knn_accuracy)
|
265 |
# st.write("K-Nearest Neighbors Classification Report:", pd.DataFrame(knn_classification_report))
|
266 |
|
267 |
if models == "K- Means Clustering":
|
|
|
269 |
kmeans_accuracy = clf.evaluate_model(kmeans_model)
|
270 |
accuracy_dict[models] = kmeans_accuracy
|
271 |
# knn_classification_report = clf.evaluate_classification_report(knn_model)
|
272 |
+
# st.write("K-Nearest Neighbors Accuracy:", kmeans_accuracy)
|
273 |
# st.write("K-Nearest Neighbors Classification Report:", pd.DataFrame(knn_classification_report))
|
274 |
|
275 |
+
st.divider()
|
276 |
+
st.write("Models Accuracy:", accuracy_dict)
|
277 |
max_key = ''
|
278 |
max_value = 0
|
279 |
for i in accuracy_dict:
|
|
|
281 |
max_key = i
|
282 |
max_value = accuracy_dict[i]
|
283 |
|
284 |
+
st.write("Efficient Model is :",max_key, accuracy_dict[max_key])
|
285 |
+
st.divider()
|
286 |
+
st.write("Scroll up and Click on <**Test**> tab to test Model performance")
|
287 |
|
288 |
+
with test:
|
289 |
+
st.title("Classification / Test")
|
290 |
spectra_1 = st.file_uploader("Upload file test the model", type={"csv", "txt"})
|
291 |
|
292 |
if spectra_1 is not None:
|
|
|
294 |
Actual = spectra_df1['Disease']
|
295 |
spectra_df1 = spectra_df1.drop(columns=['Disease'])
|
296 |
st.write(spectra_df1.head(5))
|
297 |
+
st.divider()
|
298 |
|
299 |
model_dict ={
|
300 |
"Naive Bayes Classifier":'GaussianNB()',
|
|
|
347 |
kmeans_model =kmeans_model.predict(X)
|
348 |
st.write("K-Means Clustering Model:", kmeans_model)
|
349 |
|
350 |
+
st.divider()
|
351 |
+
|
352 |
data_frame = pd.DataFrame(X).to_csv().encode('utf-8')
|
353 |
st.download_button(
|
354 |
label="Download data as CSV",
|
|
|
357 |
mime='text/csv',
|
358 |
)
|
359 |
|
360 |
+
st.divider()
|
361 |
+
|
362 |
elif choice == "Regressor":
|
363 |
regressor()
|
364 |
elif choice == "NLP":
|