> ML SERIES :: further learning

Next steps · after page 14

Further learning

The demos in this series run in your browser. The next step is writing real code on real data. Start with a free notebook in Google Colab, then use the courses, books, and datasets below to keep going.

Run your first model in five minutes

1.Go to colab.research.google.com and sign in with a Google account.
2.Choose New notebook. NumPy, pandas, scikit-learn, matplotlib, and PyTorch are already installed.
3.Paste the code below into a cell and press Shift + Enter.
4.Change the model, the features, or the threshold, and rerun. Compare with what you saw on pages 06 to 09.
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report

X, y = load_breast_cancer(return_X_y=True)            # a built-in dataset: 569 rows, 30 features
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y, random_state=0)

scaler = StandardScaler().fit(X_train)                     # page 05
model = LogisticRegression(C=1.0)                          # page 08, C = 1/lambda from page 07
model.fit(scaler.transform(X_train), y_train)

y_pred = model.predict(scaler.transform(X_test))
print(classification_report(y_test, y_pred))             # page 09

Prefer working locally? Install Python from python.org, then follow the virtual environment steps on page 03.

Courses and videos

Books and documentation

Datasets to practice on

Handle security datasets with care. Some contain real malware samples or captured traffic. Work in an isolated lab environment, never on a production or personal machine, and follow each dataset's license.

AI security frameworks