Multivariate Logistic Regression
Multivariate Logistic Regression extends univariate logistic regression by using two or more input features together to predict a categorical target - just as multiple linear regression extends simple linear regression for continuous targets.
The Equation
z = b0 + b1*x1 + b2*x2 + ... + bn*xn
p = sigmoid(z) = 1 / (1 + e^(-z))
# p = predicted probability of the positive class
Implementing in Python
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
df = pd.DataFrame({
"HoursStudied": [1, 2, 3, 4, 5, 6, 7, 8],
"AttendancePercent": [50, 55, 65, 70, 78, 85, 90, 95],
"Passed": [0, 0, 0, 1, 1, 1, 1, 1]
})
X = df[["HoursStudied", "AttendancePercent"]]
y = df["Passed"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)
model = LogisticRegression()
model.fit(X_train, y_train)
print("Coefficients:", model.coef_)
print("Predictions:", model.predict(X_test))
Interpreting the Coefficients
Each coefficient reflects how the log-odds of the positive class change with a one-unit increase in that feature, holding the other features constant - a positive coefficient increases the probability, a negative one decreases it.
Coming Up Next
Next, you'll walk through the practical process of building a Logistic Regression model step by step.