A training dataset is the portion of data used to fit a machine learning model’s parameters. Its composition directly affects what the model learns, including potential patterns of bias. section 8.0 section 9.3.2
A practical predictive-modeling workflow treats the training dataset as one part of an evaluation design:
- Split the dataset into separate training and testing sets, using 80% for training and 20% for testing. section 9.3.2
- Fit the model on the training data only, then generate predictions for the testing data. section 9.3.2
- Compare training and test performance to assess whether predictions generalize to unseen data. section 9.3.2
- Inspect the data’s representativeness and fairness because biased inputs can produce unreliable or harmful decisions. section 8.0
Predicting rat-sighting complaints
A regression workflow uses weather predictors and weekday information to fit a model on training data, then compares test and training metrics. Example results show training RMSE of 0.84 versus test RMSE of 0.90, and training R-squared of 0.61 versus test R-squared of 0.57. section 9.3.2
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
from sklearn.linear_model import LinearRegression #1
X = rats_weather[["high_temp", "wind_speed", "weekday"]]
y = np.sqrt(rats_weather["rat_sightings"]) #2
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=99
) #3
model = LinearRegression()
model.fit(X_train, y_train) #4
A scikit-learn listing demonstrates selecting predictors, splitting the data with a fixed random state, and fitting linear regression on the training subset. section 9.3.2



































