Challenge

Project 1

OBJECTIVE: Logistic regression to be performed with simple random sampling & stratified sampling and identify the differences between the two sampling methods.

SOLUTION PROCEDURE:

Logistics regression is to make the predict the target value with the inputs of the feature matrix, they use the line equation for the prediction.

  • Importing the required libraries & functions
  • Loading the data into the data frame & taking one of the faults as target (y)& features as (x).
  • Feature & target matrix are split into test & train data to get better understanding of the trained model with the simple random sampling & stratified sampling.
  • StandardScaler () function is used to scale the model since the logistic regression is affected by the scale of the data inputs
  • With the help of inbuilt functions, parameters are obtained for the training data set & then with those data, predictions are made for test data.
  • We determine the accuracy & time taken for the simple random sampling & stratified sampling.
  • We also plotting the test data with the predicted data with simple random & stratified random sampling.
  • We plot the confusion matrix to understand in detail how the prediction of target data happened with simple random sampling & stratified sampling.

CODE & OUTPUT: Jupyter notebook attached

CONCLUSION:

Based on comparison we have found the pros & cons with simple and random sampling.

Simple random sampling:

Pros: Slightly higher accuracy prediction which is shown by the score & the number of false negatives in the confusion matrix

Cons:7 samples reported as False positive since a fault is reported as not a fault

Stratified sampling:

Pros: Significant reduction in the time taken to fit the model

Cons: 48 samples are reported as False positive which is over protective compared to the simple random sampling but not bad as compared to having results of False positive

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.