Understand the idea
A network combines weighted inputs, activations and learned layers. Hidden width counts units within a layer; a tuple describes successive hidden layers. Task-specific outputs come after the shared representation.
Python skill: Use a one-item tuple and keyword arguments to describe a neural-network architecture.
Meet the syntax
(24,)
MLPClassifier
model.get_params()['hidden_layer_sizes'](24,)- A tuple with one item: one hidden layer containing 24 units. The comma makes it a tuple.
MLPClassifier- Constructs a classifier; weights are learned only when fit is called.
model.get_params()['hidden_layer_sizes']- Reads the architecture setting without fitting a network.
Follow the code
Use the numbered comments to connect each Python block to the workflow above.
from sklearn.neural_network import MLPClassifier
model = MLPClassifier(hidden_layer_sizes=(24,), max_iter=500, random_state=42)
answer = model.get_params()['hidden_layer_sizes']
This practice: Read and run the Python. Next: Change · From inputs to network outputs.
Given data · LINE24
24 observations. Deterministic teaching observations; values illustrate the concept rather than a real population claim. The dataframe df is supplied afresh for each Run.
| distance | duration |
|---|---|
| 1 | 5.30501 |
| 1.47826 | 11.2361 |
| 1.95652 | 11.8488 |
| 2.43478 | 14.809 |
| 2.91304 | 10.7589 |
| 3.3913 | 19.4972 |
| 3.86957 | 17.89 |
| 4.34783 | 15.531 |
Column meanings and units
Column names describe the supplied features and target. Keep the stated units and row identities when making comparisons.
Synthetic data are deliberately small and reproducible. Their patterns illustrate an idea; they are not evidence about a real population.
| Column | Stored type |
|---|---|
| distance | float64 |
| duration | float64 |
Your task · Follow
Create an unfitted network with one hidden layer of 24 units. Store the hidden_layer_sizes setting in answer.
Hint 1 — Think
Use a one-item tuple and keyword arguments to describe a neural-network architecture.
Hint 2 — Tools
Use (24,), MLPClassifier, model.get_params()['hidden_layer_sizes']. Read the visible syntax meanings before editing.
Hint 3 — Approach
Create an unfitted network with one hidden layer of 24 units. Store the hidden_layer_sizes setting in answer. Keep the supplied row order and inspect the named output after running.
Explained solution
from sklearn.neural_network import MLPClassifier
model = MLPClassifier(hidden_layer_sizes=(24,), max_iter=500, random_state=42)
answer = model.get_params()['hidden_layer_sizes']
The tuple (24,) means one hidden layer, not 24 layers. Constructing the estimator does not train weights or produce predictions. Regression uses MLPRegressor but shares this architecture notation.
Helpful prior knowledge: Supervised Workflow checkpoint These links are guidance, not locks.
Sources and API context
Examples run with this Playground’s scikit-learn 1.4.2 / Pyodide 0.26.4 runtime.