Regressione con alberi decisionali
Suddivisioni non lineari dei dati.
Regressione con alberi decisionali è una lezione Data Science Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Data Science Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Data Science Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Beyond Straight Lines
A decision tree predicts numbers by asking yes-or-no questions about your features, splitting the data step by step. No straight line required. 🌳
Splits Are the Questions
Each branch is a split, like is size above 80? The tree keeps asking, narrowing rows into smaller and smaller groups.
Leaves Hold the Answer
At the bottom sit the leaves. Each leaf predicts one number: the average target of all training rows that landed there.
Choosing the Best Split
The tree tries many split points and keeps the one that most reduces prediction error in the resulting groups. Greedy, one step at a time.
Train One in Two Lines
The familiar fit-predict contract holds. Create a DecisionTreeRegressor, fit it, and predict just like any other estimator.
from sklearn.tree import DecisionTreeRegressor
model = DecisionTreeRegressor().fit(X, y)Predictions Look Like Steps
Because each leaf gives one flat value, a tree's predictions form a staircase, not a smooth curve. That is fine for many real patterns.
Trees Catch Non-Linear Shapes
Splits can bend any direction, so a tree captures non-linear relationships that a line would completely miss. That is its real strength.
Deep Trees Overfit
Left unchecked, a tree grows until each leaf holds one row, memorizing noise. That deep tree overfits and fails on new data.
Limit the Depth
Control growth with max_depth. A shallower tree stays general and is far easier to read and trust.
DecisionTreeRegressor(max_depth=4)More Pruning Knobs
You can also set min_samples_leaf so leaves keep enough rows. This stops the tree from carving out tiny, noisy groups.
DecisionTreeRegressor(min_samples_leaf=10)No Scaling Needed
Trees split on thresholds, so feature units do not matter. You can skip scaling, a nice contrast to Ridge and Lasso.
Quick Check
Think about how a tree turns rows into a prediction.
Recap
A decision tree splits data with questions, predicts a leaf average, and bends to non-linear shapes. Cap its depth so it generalizes. 🎯
Domande Frequenti
La lezione «Regressione con alberi decisionali» è gratuita?
Sì — il testo completo di «Regressione con alberi decisionali» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Data Science Academy, passa a CoddyKit PRO. Il corso Data Science Academy include 4 lezioni in totale.
Cosa imparerò in «Regressione con alberi decisionali»?
Suddivisioni non lineari dei dati. Eserciti Data Science Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Data Science Academy?
Non è richiesta alcuna esperienza precedente. Data Science Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.
Quanto tempo richiede la lezione «Regressione con alberi decisionali»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Data Science Academy?
Sì. Ogni lezione Data Science Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Riprendere la regressione lineare
- Regolarizzazione Ridge e Lasso
- Regressione con alberi decisionali
- Random Forest per la regressione