Fit Before Split
scaler = StandardScaler().fit(X) # line 1
X_scaled = scaler.transform(X) # line 2
X_tr, X_te, y_tr, y_te = train_test_split(X_scaled, y) # line 3
model = Ridge().fit(X_tr, y_tr) # line 4
print(model.score(X_te, y_te)) # line 5
The score printed at line 5 is optimistic. Which line is the defect, and what exactly crossed the boundary?
Sign in to answer questions and track your progress
Sign In