0% found this document useful (0 votes)
4 views

Cheat Sheet 2.0 Copy 4

Uploaded by

arizaxel16
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Cheat Sheet 2.0 Copy 4

Uploaded by

arizaxel16
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Axel

Evaluation Metrics &


Perceptron Confusion Matrix
Model: Binary classifier using a step
function.​
Weight Update Rule:

Adaline (Adaptive Linear


Neuron)
Model: Similar to Perceptron, but
minimizes MSE.​
Weight Update (via Gradient Descent)

Data Standardization​

Logistic Regression
Purpose: Classification by estimating
probability.
Hyperparameters &
Regularization
●​ Common Hyperparameters:​

○​ Learning Rate (η): Step


size in gradient descent.​
Gradient Descent ○​ Epochs: Number of full
passes through the
dataset.​

○​ Batch Size: Number of


samples per update.

# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.3, random_state=42)

# Create and train the logistic regression model


model = LogisticRegression()
model.fit(X_train, y_train)

# Predict on test data


●​ C (Inverse Regularization y_pred = model.predict(X_test)
Strength):​ # Compute metrics
Lower C → stronger cm = confusion_matrix(y_test, y_pred)
regularization (commonly in acc = accuracy_score(y_test, y_pred)
prec = precision_score(y_test, y_pred)
logistic regression/SVM).​ rec = recall_score(y_test, y_pred)
f1 = f1_score(y_test, y_pred)

Bayesian Models​

Manual Learning Phase


Example

Model Training Snippets


from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix,
accuracy_score, precision_score, recall_score,
f1_score

X, y = make_classification(n_samples=200,
n_features=2, n_redundant=0,
n_clusters_per_class=1,
random_state=42)

You might also like