Spaces:
Sleeping
Sleeping
Update pages/1_User_Defined_DataLab.py
Browse files
pages/1_User_Defined_DataLab.py
CHANGED
|
@@ -14,14 +14,26 @@ st.set_page_config(layout="wide")
|
|
| 14 |
st.title("🧠 Neural Network Playground - Custom Dataset")
|
| 15 |
|
| 16 |
# Generate synthetic 2-feature dataset
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
df = pd.DataFrame(X, columns=["X1", "X2"])
|
| 27 |
df["label"] = y
|
|
|
|
| 14 |
st.title("🧠 Neural Network Playground - Custom Dataset")
|
| 15 |
|
| 16 |
# Generate synthetic 2-feature dataset
|
| 17 |
+
from sklearn.datasets import make_classification, make_circles, make_moons
|
| 18 |
+
|
| 19 |
+
# Dataset selection
|
| 20 |
+
st.sidebar.title("📦 Dataset Settings")
|
| 21 |
+
dataset_type = st.sidebar.selectbox("Choose Dataset Type", ["Linear (make_classification)", "Circles (make_circles)", "Moons (make_moons)"])
|
| 22 |
+
|
| 23 |
+
n_samples = st.sidebar.slider("Number of Samples", 100, 1000, 300)
|
| 24 |
+
noise = st.sidebar.slider("Noise Level", 0.0, 1.0, 0.2)
|
| 25 |
+
random_state = st.sidebar.number_input("Random State", value=42)
|
| 26 |
+
|
| 27 |
+
if dataset_type == "Linear (make_classification)":
|
| 28 |
+
n_clusters_per_class = st.sidebar.slider("Number of Clusters", 1, 4, 1)
|
| 29 |
+
X, y = make_classification(n_samples=n_samples, n_features=2, n_redundant=0,
|
| 30 |
+
n_informative=2, n_clusters_per_class=n_clusters_per_class,
|
| 31 |
+
flip_y=noise, random_state=random_state, class_sep=4)
|
| 32 |
+
elif dataset_type == "Circles (make_circles)":
|
| 33 |
+
X, y = make_circles(n_samples=n_samples, noise=noise, factor=0.5, random_state=random_state)
|
| 34 |
+
elif dataset_type == "Moons (make_moons)":
|
| 35 |
+
X, y = make_moons(n_samples=n_samples, noise=noise, random_state=random_state)
|
| 36 |
+
|
| 37 |
|
| 38 |
df = pd.DataFrame(X, columns=["X1", "X2"])
|
| 39 |
df["label"] = y
|