Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Machine Learning · Learn / Refresh

← Neural Networks lessons
Shared network concepts · ML-N-R1 · 15–20 MIN

Shared network retrieval

  1. Retrieval 1Compute and inspect the evidenceCurrent exercise
  2. Retrieval 2Compute and inspect the evidence
  3. Retrieval 3Compute and inspect the evidence

Outputs you create

answer
  1. The requested result, with the values, labels and row order described by this task.
Exercise evidence · ML-N-R1-1 · all 4 rows
material_code
0
1
2
3
Your task
  1. Make the unfitted four-class-task network with hidden widths 16 then 8.
  2. Store its hidden_layer_sizes in answer; the number of output classes is learned from labels during fit.
answer
Hints

Think: The tuple lists only hidden-layer widths. Classification output classes follow the fitted material labels; numeric category codes do not turn those labels into a regression quantity.

Tools: Shared network retrieval: use the supplied material_code columns and the pandas or model operations introduced in this lesson.

Approach: Compute answer from the supplied evidence. Preserve the requested labels and row order, then inspect the values before checking.

Explained solution
from sklearn.neural_network import MLPClassifier
model = MLPClassifier(hidden_layer_sizes=(16,8), random_state=42)
answer = model.hidden_layer_sizes
print(answer)

The tuple lists only hidden-layer widths. Classification output classes follow the fitted material labels; numeric category codes do not turn those labels into a regression quantity.

Ctrl/⌘+Enter: Run · Tab: indent · Esc then Tab: leave editor

Python loads when you run. Code and results stay in this activity only.

Run your code to inspect its output. Check uses that same run.