Eine lineare Regression trainieren
Ein vollständiges Beispiel von Anfang bis Ende
Eine lineare Regression trainieren ist eine kostenlose Data Science Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Data Science Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Data Science Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
A Line Through Data
Linear regression fits a straight-line relationship between your features and a numeric target. It is the classic first model for a reason. 📈
Import the Model
The estimator lives in the linear_model module. You import it once and reuse it for any regression task you meet.
from sklearn.linear_model import LinearRegressionCreate an Instance
Build a fresh model by calling the class. This blank estimator holds default settings and has not seen any data yet.
model = LinearRegression()Fit on Training Data
Now teach it with your features and target. During fit, the model finds the best line through your training points.
model.fit(X_train, y_train)Read the Slope
Each feature gets a coefficient stored in coef_. It tells you how much the prediction moves when that feature rises by one.
model.coef_Read the Intercept
The intercept is the prediction when every feature is zero. It anchors the line and is stored in intercept_ after fitting.
model.intercept_Make Predictions
Hand new feature rows to predict and you get numeric estimates back, one per row, computed straight from the fitted line.
y_pred = model.predict(X_test)The Equation Behind It
Under the hood, each prediction is just features times coefficients plus the intercept. Simple math, surprisingly powerful results.
One Feature or Many
The same call handles a single feature or dozens. With many inputs it fits a hyperplane, but your code stays exactly the same.
Linear Means a Straight Fit
Linear regression assumes a roughly straight relationship. If the pattern curves sharply, this model will underfit and miss it.
The Full Workflow
Import, create, fit, predict: four steps and you have a working regressor. This same rhythm repeats for every model you learn next.
Quick Check
Which attribute holds the per-feature weights after fitting?
Recap
You imported, created, fit, and predicted with a linear regression. Its coef_ and intercept_ even reveal what it learned. 🚀
Häufig gestellte Fragen
Ist die Lektion „Eine lineare Regression trainieren“ kostenlos?
Ja — der vollständige Text von „Eine lineare Regression trainieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Data Science Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Data Science Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Eine lineare Regression trainieren“?
Ein vollständiges Beispiel von Anfang bis Ende Du übst Data Science Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Data Science Academy zu starten?
Keine Vorkenntnisse erforderlich. Data Science Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.
Wie lange dauert die Lektion „Eine lineare Regression trainieren“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Data Science Academy-Lektion Code schreiben und ausführen?
Ja. Jede Data Science Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Der fit- und predict-Vertrag
- Merkmale X und Zielgröße y
- Eine lineare Regression trainieren
- Ihr erstes Modell bewerten