0% found this document useful (0 votes)
6 views1 page

Logistic Regression Code

The document provides a Python code snippet that computes the dot product of two vectors and applies the sigmoid function to the result. It also evaluates the suitability of logistic regression for three different prediction scenarios, confirming its appropriateness for binary classification tasks like fraud detection and student performance, while deeming it unsuitable for predicting continuous outcomes like car prices.

Uploaded by

xebakeh884
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Logistic Regression Code

The document provides a Python code snippet that computes the dot product of two vectors and applies the sigmoid function to the result. It also evaluates the suitability of logistic regression for three different prediction scenarios, confirming its appropriateness for binary classification tasks like fraud detection and student performance, while deeming it unsuitable for predicting continuous outcomes like car prices.

Uploaded by

xebakeh884
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import numpy as np

# Given vectors
x = np.array([1, 2])
w = np.array([0.5, 1.0])

# 1. Compute z = w^T x
z = np.dot(w, x)

# 2. Compute sigmoid(z)
def sigmoid(z):
return 1 / (1 + np.exp(-z))

sigma_z = sigmoid(z)

print("z =", z)
print("sigma(z) =", sigma_z)

Output:
z = 2.5
sigma(z) = 0.9241418199787566

1. Predicting if a bank transaction is fraud (yes/no)

✅ Suitable for Logistic Regression

Why: This is a binary classification problem (fraud or not fraud), which is exactly what logistic regression is designed for.

---

2. Predicting the price of a used car

❌ Not Suitable for Logistic Regression

Why: This is a regression problem with a continuous numeric output (price). Linear regression or other regression algorithms are more appropriate.

---

3. Predicting if a student will pass or fail based on hours studied

✅ Suitable for Logistic Regression

Why: This is a binary classification task (pass or fail), and logistic regression works well when the outcome is categorical and binary.

You might also like