CSE 163
Section AX
Week 7
TA 1 & TA 2
STAT
Housekeeping🧹
Important Dates:
2
Section Plan
🃏🎴
In today’s section, we’ll go over
3
Statistics 101
4
Examples of Summary Statistics
Distributions
Hypothesis Tests
Null Hypothesis is the hypothesis that supports the pre-existing expectations or probability
Alternative Hypothesis is the hypothesis that something is different, one that if true, would allow us to reject the null hypothesis
Our p-value is the chance that this situation would happen in a world bound by the null hypothesis
P-hacking and HARKing
6
ML pipeline for regression tasks
7
# Separate data
features = data.loc[:, data.columns != 'target']
labels = data['target']
# Create and train model
model = DecisionTreeRegressor()
model.fit(features, labels)
# Predict on some data
predictions = model.predict(features)
# Assess accuracy
mean_squared_error(labels, predictions)
ML pipeline for classification tasks
8
# Separate data
features = data.loc[:, data.columns != 'target']
labels = data['target']
# Create and train model
model = DecisionTreeClassifier()
model.fit(features, labels)
# Predict on some data
predictions = model.predict(features)
# Assess accuracy
accuracy_score(labels, predictions)
Train-test split
The goal of machine learning is not to memorize the labels of the data we already have, but to learn a model that generalizes to future, unseen data.
from sklearn.model_selection import train_test_split
# Breaks data into 80% train and 20% test
X_train, X_test, y_train, y_test =
train_test_split(X, y, test_size=0.2)
Underfitting vs. overfitting
Models won’t always perform well on test data.
Suppose we’re training a classification model…
We want our models to be somewhere in between the two!
Practice Problems!
11
Project Check In
Discussion Questions:
After discussing, group members should ask follow-up questions or offer insights!
Section Code:
13
Solutions
14
Solutions
15