Understand the idea
Training adjusts weights to reduce an objective. Comparable feature scales help optimisation. Different initialisations can produce different learning trajectories. Training loss is not validation performance.
Illustrative data
Final training loss: 0.325. Training loss measures the fitting objective, not validation performance.
answer = pd.Series(network.loss_curve_, name="training_loss")
answer.index = answer.index + 1
answer.index.name = "iteration"What the syntax does
network.loss_curve_- The training objective after each optimisation iteration; these values are not final-test errors.
pd.Series(network.loss_curve_, name='training_loss')- Labels the recorded sequence so its meaning is clear in the output.
Supplied for this practice
These objects are prepared afresh before your editor runs.
X_train/X_test/y_train/y_test- Training feature rows from the declared split. Final-test feature rows from the declared split. Training targets, aligned with
X_train. Final-test targets, aligned withX_test.X_train, X_test, y_train, y_test = train_test_split(df[['length', 'width']], df['label'], test_size=0.2, random_state=42, stratify=df['label']) model- Already fitted on
X_train,y_train. Fitted estimator or pipeline for the requested model family. Fitted onX_train,y_train; reuse without refitting. network- Already fitted on
X_train,y_train. Supplied network; its definition below specifies the values and role. Fitted onX_train,y_train; reuse without refitting.
Outputs you create
answer- The requested result, with the values, labels and row order described by this task.
length | width | label |
|---|---|---|
| 236.033 | -0.805568 | A |
| 581.297 | 0.728558 | A |
| -1511.27 | -1.00866 | A |
| 99.0248 | -0.24496 | A |
| -13.0141 | -0.660765 | A |
| 681.179 | 0.602475 | A |
| 51.1472 | 0.873157 | A |
| 362.131 | -0.665605 | A |
- Store the fitted
network’s loss history inansweras aSeries, keeping the training order. - Call its index iteration.
- Consecutive iteration labels may start at 0 or 1.
answerHints
Think: Turn loss_curve_ into an indexed Series to inspect how optimisation changed training loss.
Tools: Use network.loss_curve_, pd.Series(network.loss_curve_, name='training_loss'). Read the visible syntax meanings before editing.
Approach: Store the fitted network’s loss history in answer as a Series, keeping the training order. Call its index iteration. Consecutive iteration labels may start at 0 or 1. Keep the supplied row order and inspect the named output after running.
Explained solution
answer = pd.Series(network.loss_curve_, name='training_loss')
answer.index = answer.index + 1
answer.index.name = 'iteration'
Each loss value describes the training objective at one iteration. Reducing this objective guides weight updates. Falling training loss does not prove good predictions on new rows; validation evidence answers that separate question.