Objective. Students will train linear regression and logistic regression models, interpret coefficients, and evaluate results using RMSE/R² and accuracy/confusion matrix respectively.
This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.
VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.
Regression models are among the most widely used tools in data analytics. Understanding how they work mathematically—and how to explain them clearly to a non-technical audience—is a core competency for any data professional.
Linear regression models the relationship between one or more input features and a continuous numeric target. The simplest case, simple linear regression, fits a straight line: ŷ = β₀ + β₁x, where β₀ is the intercept and β₁ is the slope. With multiple features you extend this to ŷ = β₀ + β₁x₁ + β₂x₂ + … + βₙxₙ.
Ordinary Least Squares (OLS) finds the coefficients that minimize the sum of squared residuals—the squared differences between each actual value y and the model's prediction ŷ. Intuitively, you are finding the line (or hyperplane) that sits as close as possible to all the data points at once. Each coefficient βᵢ tells you: holding all other features constant, a one-unit increase in xᵢ is associated with a βᵢ-unit change in the predicted target. This is the sentence you should be able to say to a client.
Root Mean Squared Error (RMSE) measures average prediction error in the same units as the target. Lower is better. R² (coefficient of determination) measures the proportion of variance in the target explained by the model, ranging from 0 to 1 (or negative if the model is worse than predicting the mean). An R² of 0.75 means the model explains 75% of the variability in the outcome.
Always inspect a residual plot (residuals vs. fitted values). Residuals should scatter randomly around zero. Patterns—curves, funnels—signal that the linear model is missing something: a non-linear relationship, or non-constant variance (heteroscedasticity).
When the target is a category (yes/no, survived/did not survive), you need a model that outputs a probability between 0 and 1, not an unbounded number. Logistic regression does this by applying the sigmoid function to a linear combination of features:
P(y=1) = 1 / (1 + e^(−z)), where z = β₀ + β₁x₁ + … + βₙxₙ
The sigmoid squashes any real number into the range (0, 1). You choose a threshold—commonly 0.5—to convert that probability into a class prediction. Coefficients in logistic regression are interpreted in terms of log-odds: a one-unit increase in xᵢ multiplies the odds of the positive outcome by e^βᵢ. For a client briefing, it is clearest to say something like: passengers in first class had a substantially higher estimated probability of survival than those in third class, even after accounting for age and sex.
Accuracy is the fraction of predictions the model got right. It is easy to understand but misleading when classes are imbalanced—if 95% of cases are negative, a model that always predicts negative has 95% accuracy but is useless.
The confusion matrix breaks results into four cells: True Positives (TP), True Negatives (TN), False Positives (FP), and False Negatives (FN). From these you can compute precision (TP / (TP + FP))—how often a positive prediction is correct—and recall (TP / (TP + FN))—how many actual positives the model caught. Always report at least one metric beyond raw accuracy.
In scikit-learn, both models follow the same pattern: import the class, instantiate it, call `.fit(X_train, y_train)`, then `.predict(X_test)`. For linear regression use `LinearRegression`; for logistic regression use `LogisticRegression`. Metrics live in `sklearn.metrics`: `mean_squared_error` (take the square root for RMSE), `r2_score`, `accuracy_score`, and `confusion_matrix`. Visualize the confusion matrix as a heatmap with `seaborn.heatmap` for instant readability.
Split your data before fitting with `train_test_split`. Never evaluate a model on the same data it was trained on—this inflates performance metrics and misleads everyone, including yourself.
When working with real datasets that may contain personally identifiable information (PII)—such as names, survival records, or location data—handle them according to your organization's data governance policy. Do not upload sensitive data to public repositories. On shared lab machines, clear notebook outputs containing PII before logging off. These are professional habits that protect both the individuals in the data and your own reputation.
A strong five-sentence interpretation covers: (1) what question the model answers, (2) what the key metric means in plain language, (3) what the model's biggest limitation is, (4) one actionable insight, and (5) a caution about what the model cannot tell us. Clients make decisions based on your summaries—precision and honesty matter as much here as they do in the code.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.
Does the school offer financial aid?
No. We don’t offer financial aid because we’re free. No, really: completely free.
Do you offer industry certification?
No. We are not certified yet, so we can’t offer that to students. What we do offer is knowledge and understanding of a trade.
Enroll first in the trade you’re interested in. You get your key, your program opens, and you begin studying.
Enroll free →