DasariHarshitha commited on
Commit
4244670
Β·
verified Β·
1 Parent(s): 93e702f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from datetime import datetime
3
+
4
+ # ---------------------------
5
+ # Dummy AI Logic (Data Science Tutor)
6
+ # ---------------------------
7
+ def ds_tutor_response(user_query, chat_history):
8
+ """
9
+ Returns AI-like answers to Data Science queries.
10
+ Simulated without API key.
11
+ """
12
+ # Simple keyword-based logic for simulation
13
+ if "regression" in user_query.lower():
14
+ return "πŸ“Š Regression is a supervised ML technique used to predict continuous values. Example: predicting house prices."
15
+ elif "classification" in user_query.lower():
16
+ return "πŸ” Classification is used when the target variable is categorical (e.g., spam vs not spam)."
17
+ elif "neural network" in user_query.lower():
18
+ return "🧠 A Neural Network is inspired by the human brain. It has layers of interconnected neurons that learn patterns in data."
19
+ elif "pca" in user_query.lower():
20
+ return "πŸ“‰ PCA (Principal Component Analysis) is a dimensionality reduction technique that transforms features into fewer components."
21
+ elif "accuracy" in user_query.lower():
22
+ return "βœ… Accuracy = (Correct Predictions / Total Predictions). But for imbalanced data, metrics like F1-score are better."
23
+ else:
24
+ return "πŸ€” I'm your Data Science Tutor. Can you clarify your question in Data Science terms?"
25
+
26
+ # ---------------------------
27
+ # Streamlit UI
28
+ # ---------------------------
29
+ st.set_page_config("AI Data Science Tutor", layout="centered")
30
+ st.title("πŸŽ“ AI Conversational Data Science Tutor")
31
+
32
+ st.write("Ask me any Data Science doubt, and I'll help you understand. Memory is enabled, so I remember our conversation.")
33
+
34
+ # Session state for chat history
35
+ if "chat_history" not in st.session_state:
36
+ st.session_state.chat_history = []
37
+
38
+ # Chat UI
39
+ for msg in st.session_state.chat_history:
40
+ with st.chat_message(msg["role"]):
41
+ st.markdown(msg["content"])
42
+
43
+ # User input
44
+ user_input = st.chat_input("Ask your Data Science question...")
45
+
46
+ if user_input:
47
+ # Save user message
48
+ st.session_state.chat_history.append({"role": "user", "content": user_input})
49
+ with st.chat_message("user"):
50
+ st.markdown(user_input)
51
+
52
+ # Generate AI response
53
+ ai_reply = ds_tutor_response(user_input, st.session_state.chat_history)
54
+
55
+ # Save AI message
56
+ st.session_state.chat_history.append({"role": "assistant", "content": ai_reply})
57
+ with st.chat_message("assistant"):
58
+ st.markdown(ai_reply)