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.
1. 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 test_size=0.2 and random state=42.
-Use the following code for feature scaling.
-Standardize the features using:
StandardScaler from sklearn.preprocessing.scaler=StandardScaler()
Xtrain = scaler.fit transform(X train) X_test =scaler.transform(X_test)
2. Model Training
-Train a Logistic Regression model using LogisticRegression from sklearn.linear_model on the training data.
-Keep the default parameters.
3. Make Predictions
-Predict the classes and print them.
-Manually calculate and print the True Positives(TP), True Negatives (TN), False Positives(FP), and False Negatives(FN) using the actual and predicted classes.
-Manually calculate and print and Root Mean Squared Error(RMSE).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!