Scenario
You want to find out which process parameters affect whether welding is defective. Y is "Good / Defective," and X represents temperature, time, and pressure. A colleague suggested using regression, so you built a linear regression model. However, the predicted values came out as 1.3 (over 100%) and -0.2 (negative yield rate) – which is clearly unreasonable.
Problem: Linear regression assumes Y is a continuous variable, but your Y is only 0 or 1.
What is Logistic Regression?
Logistic regression does not predict Y itself, but rather the probability of Y = 1, and this probability is always between 0 and 1.
Core Mathematics:
P(Y=1) = 1 / (1 + e^-(β₀ + β₁X₁ + β₂X₂ + ...))
This S-shaped curve (Sigmoid) ensures the output is always within [0,1].
Interpreting Key Outputs
Odds Ratio
The coefficients of logistic regression are not intuitive to interpret directly and are usually converted into the Odds Ratio (OR):
OR = e^β
Example:
- Temperature coefficient β = 0.08
- OR = e^0.08 = 1.083
- Interpretation: For every 1°C increase in temperature, the probability of defectiveness is 1.083 times the original (an 8.3% increase).
| OR Value | Interpretation |
|---|---|
| > 1 | As X increases, the probability of Y=1 increases |
| = 1 | X has no effect on Y |
| < 1 | As X increases, the probability of Y=1 decreases |
P-value
Similar to linear regression, P < 0.05 indicates that this X has a significant effect on Y.
Hosmer-Lemeshow Test
Tests the overall goodness-of-fit of the model (similar to the F-test in regression).
P > 0.05: Model fits well
P < 0.05: Model fit is poor; consider adding other variables or interaction terms.
Common Applications in Manufacturing
| Scenario | Y (1/0) | X (Inputs) |
|---|---|---|
| Welding Yield | Defective/Good | Temperature, Time, Flux |
| Injection Molding | Shrinkage/No Shrinkage | Injection Speed, Holding Pressure, Material Temperature |
| Equipment Lifespan | Failure/Normal | Usage Time, Temperature, Vibration |
| Supplier Evaluation | Non-conforming/Conforming | Delivery Time, Unit Price, Historical Defect Rate |
Logistic Regression vs. Linear Regression
| Linear Regression | Logistic Regression | |
|---|---|---|
| Type of Y | Continuous Value | Binary (0/1) |
| Predicts | Value of Y | Probability of Y=1 |
| Output Range | -∞ to +∞ | 0 to 1 |
| Model Evaluation | R², RMSE | AUC, Confusion Matrix |
Decision Threshold
Logistic regression outputs probabilities, so you need to set a threshold for decision-making (usually 0.5):
- P ≥ 0.5 → Predicted as Defective
- P < 0.5 → Predicted as Good
The threshold can be adjusted: if the cost of a defective product is very high, it can be lowered to 0.3, preferring more false positives over missing actual defective products.
Golden Quote
"When your question is 'will it or won't it', not 'how much', logistic regression is the correct tool. Using linear regression to predict defectiveness is like using a thermometer to measure weight."