mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
50 KiB
50 KiB
In [3]:
from sklearn.datasets import make_moons
# Make 1000 samples
n_samples = 1000
# Create circles
X, y = make_moons(n_samples,
noise=0.07,
random_state=42) # keep random state so we get the same valuesIn [7]:
# Get dataframe of moons
import pandas as pd
moons = pd.DataFrame({"X1": X[:, 0],
"X2": X[:, 1],
"label": y
})
moons.head()Out [7]:
| X1 | X2 | label | |
|---|---|---|---|
| 0 | -0.033411 | 0.421391 | 1 |
| 1 | 0.998827 | -0.442890 | 1 |
| 2 | 0.889592 | -0.327843 | 1 |
| 3 | 0.341958 | -0.417690 | 1 |
| 4 | -0.838531 | 0.532375 | 0 |
In [8]:
# Check different labels
moons.label.value_counts()Out [8]:
1 500 0 500 Name: label, dtype: int64
In [10]:
# Visualize with a plot
import matplotlib.pyplot as plt
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.RdYlBu)Out [10]:
<matplotlib.collections.PathCollection at 0x7f53bb9db580>
In [11]:
# UPTOHERE - building a model In [ ]: