liveBook · Manning

Training dataset

As explained in Effective Data Analysis

A training set is the portion of data used to fit the parameters of a machine learning model.

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

How Effective Data Analysis covers it

How deep it goes
Explains dataset splitting, training-only fitting, prediction, and metric comparison, but does not detail parameter optimization internals.
Examples
Uses a rat-sighting regression dataset and an applicant-resume dataset to illustrate evaluation and dataset bias.
What it assumes
Assumes familiarity with datasets and predictive models while establishing the training-versus-testing distinction operationally.
What you can do after
Apply it via scikit-learn by splitting data, fitting on the training subset, predicting on test data, and comparing performance.
How it connects
Connects training datasets to testing sets, predictive modeling, regression, scikit-learn, RMSE, and R-squared.

Also explained in

Compare how 36 books explain training dataset →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.