Spaces:
Sleeping
Sleeping
Update pages/Lifecycle of Machine Learning.py
Browse files
pages/Lifecycle of Machine Learning.py
CHANGED
@@ -1,46 +1,54 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
# HTML and CSS code for a simple mind map
|
4 |
-
html_code = """
|
5 |
-
<div style="display: flex; justify-content: center; margin-top: 20px;">
|
6 |
-
<div style="text-align: center;">
|
7 |
-
<!-- Root Node -->
|
8 |
-
<div style="background-color: #4CAF50; color: white; padding: 10px 20px; border-radius: 10px; margin-bottom: 20px;">
|
9 |
-
Data Science
|
10 |
-
</div>
|
11 |
-
<div style="display: flex; justify-content: space-around;">
|
12 |
-
<!-- First Branch -->
|
13 |
-
<div style="text-align: center; margin-right: 50px;">
|
14 |
-
<div style="background-color: #f44336; color: white; padding: 10px 20px; border-radius: 10px;">
|
15 |
-
Machine Learning
|
16 |
-
</div>
|
17 |
-
<div style="margin-top: 20px;">
|
18 |
-
<div style="background-color: #e91e63; color: white; padding: 10px 20px; border-radius: 10px; margin-top: 10px;">
|
19 |
-
Supervised
|
20 |
-
</div>
|
21 |
-
<div style="background-color: #e91e63; color: white; padding: 10px 20px; border-radius: 10px; margin-top: 10px;">
|
22 |
-
Unsupervised
|
23 |
-
</div>
|
24 |
-
</div>
|
25 |
-
</div>
|
26 |
-
<!-- Second Branch -->
|
27 |
-
<div style="text-align: center; margin-left: 50px;">
|
28 |
-
<div style="background-color: #2196F3; color: white; padding: 10px 20px; border-radius: 10px;">
|
29 |
-
Deep Learning
|
30 |
-
</div>
|
31 |
-
<div style="margin-top: 20px;">
|
32 |
-
<div style="background-color: #03A9F4; color: white; padding: 10px 20px; border-radius: 10px; margin-top: 10px;">
|
33 |
-
CNN
|
34 |
-
</div>
|
35 |
-
<div style="background-color: #03A9F4; color: white; padding: 10px 20px; border-radius: 10px; margin-top: 10px;">
|
36 |
-
RNN
|
37 |
-
</div>
|
38 |
-
</div>
|
39 |
-
</div>
|
40 |
-
</div>
|
41 |
-
</div>
|
42 |
-
</div>
|
43 |
-
"""
|
44 |
-
|
45 |
-
# Display the mind map in Streamlit
|
46 |
-
st.markdown(html_code, unsafe_allow_html=True)
|
|
|
1 |
import streamlit as st
|
2 |
+
from sklearn.datasets import load_iris
|
3 |
+
from sklearn.model_selection import train_test_split
|
4 |
+
from sklearn.ensemble import RandomForestClassifier
|
5 |
+
from sklearn.metrics import accuracy_score
|
6 |
+
|
7 |
+
# Page Title
|
8 |
+
st.title("Machine Learning Life Cycle in Streamlit")
|
9 |
+
|
10 |
+
# Buttons for each stage
|
11 |
+
if st.button("1. Data Collection"):
|
12 |
+
st.header("Data Collection")
|
13 |
+
st.write("Using Iris dataset for demonstration.")
|
14 |
+
data = load_iris(as_frame=True)
|
15 |
+
st.write(data.frame.head())
|
16 |
+
|
17 |
+
elif st.button("2. Data Preprocessing"):
|
18 |
+
st.header("Data Preprocessing")
|
19 |
+
st.write("Splitting the data into train and test sets.")
|
20 |
+
data = load_iris(as_frame=True)
|
21 |
+
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=42)
|
22 |
+
st.write(f"Train size: {len(X_train)}; Test size: {len(X_test)}")
|
23 |
+
|
24 |
+
elif st.button("3. Model Training"):
|
25 |
+
st.header("Model Training")
|
26 |
+
st.write("Training a Random Forest Classifier.")
|
27 |
+
data = load_iris(as_frame=True)
|
28 |
+
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=42)
|
29 |
+
model = RandomForestClassifier()
|
30 |
+
model.fit(X_train, y_train)
|
31 |
+
st.write("Model trained successfully.")
|
32 |
+
|
33 |
+
elif st.button("4. Model Evaluation"):
|
34 |
+
st.header("Model Evaluation")
|
35 |
+
st.write("Evaluating the model on the test data.")
|
36 |
+
data = load_iris(as_frame=True)
|
37 |
+
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=42)
|
38 |
+
model = RandomForestClassifier()
|
39 |
+
model.fit(X_train, y_train)
|
40 |
+
predictions = model.predict(X_test)
|
41 |
+
accuracy = accuracy_score(y_test, predictions)
|
42 |
+
st.write(f"Accuracy: {accuracy:.2f}")
|
43 |
+
|
44 |
+
elif st.button("5. Model Deployment"):
|
45 |
+
st.header("Model Deployment")
|
46 |
+
st.write("This step involves deploying the model for usage.")
|
47 |
+
st.write("You can expose the model via APIs or integrate it into an application.")
|
48 |
+
|
49 |
+
else:
|
50 |
+
st.write("Use the buttons above to navigate through the Machine Learning life cycle.")
|
51 |
+
|
52 |
+
|
53 |
+
streamlit run ml_lifecycle.py
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|