PPT for Assignment-8 (Logistic Regression)
PPT for Assignment-8 (Logistic Regression)
Logistic Regression
What is Logistic Regression?
• Logistic regression is used for classification problems.
• Unlike linear regression, it predicts probabilities (values
between 0 and 1).
• Uses the sigmoid function to map predictions.
Understanding the Iris Dataset
• The Iris dataset is widely used in ML.
• It contains 150 samples of 3 flower species (Setosa,
Versicolor, Virginica).
• Each sample has 4 features: Sepal Length, Sepal Width,
Petal Length, Petal Width.
Understanding the Iris Dataset
• The Iris dataset is widely used in ML.
• It contains 150 samples of 3 flower species (Setosa,
Versicolor, Virginica).
• Each sample has 4 features: Sepal Length, Sepal Width,
Petal Length, Petal Width.
Loading the Iris Dataset in Python
• Import datasets from sklearn and load the dataset.
• from sklearn import datasets
• iris = datasets.load_iris()
• X = iris.data
• y = iris.target
• X contains features, y contains target labels (0, 1, 2).
Splitting the Dataset
Why do we split the data? To train and test separately.
Answer-We split the data into training and testing sets to ensure that our
model learns from one part of the data and is evaluated on another, unseen
part.
Code:
• scaler = StandardScaler()
Training the Logistic Regression Model
We use LogisticRegression from sklearn.
y_pred = model.predict(X_test)