Question: Logistic Regression * in python Objective: Implement Logistic Regression from scratch to classify the Iris dataset and compute the True Positive, False Positive, True Negative,
Logistic Regression
in python
Objective: Implement Logistic Regression from scratch to classify the Iris dataset and compute the True Positive, False Positive, True Negative, False Negative rates.
Load and Preprocess the Iris Dataset
Load the Iris dataset from sklearn.datasets.
Extract only the first two classes to make it a binary classification problem.
Split the dataset into features X and target labels y
Split the dataset into training and testing sets using train test split with testsize and random state
Use the following code for feature scaling.
Standardize the features using:
StandardScaler from sklearn.preprocessing.scalerStandardScaler
Xtrain scaler.fit transformX train Xtest scaler.transformXtest
Model Training
Train a Logistic Regression model using LogisticRegression from sklearn.linearmodel on the training data.
Keep the default parameters.
Make Predictions
Predict the classes and print them.
Manually calculate and print the True PositivesTP True Negatives TN False PositivesFP and False NegativesFN using the actual and predicted classes.
Manually calculate and print and Root Mean Squared ErrorRMSE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
