Skip to content
CampusEduX

Problem 4: Apply a Custom Decision Threshold

Easypython
Learn the Concept: Logistic Regression

Problem Description

Write a Python program that trains a Logistic Regression model, retrieves predicted probabilities, and applies a custom threshold of 0.3 (instead of the default 0.5) to generate class predictions.

Input

Training data and new examples to classify with the custom threshold.

Output

Class predictions based on the 0.3 threshold.

Constraints

  • None specific.

Example Input

text
X=[[1],[2],[7],[8]], y=[0,0,1,1], new=[[4]], threshold=0.3

Example Output

text
Probability: 0.45 Prediction with 0.3 threshold: 1

Concepts Covered

.predict_proba(), custom threshold logic, conditionals.

Related Problems

  • Problem 1: Train a Basic Logistic Regression Classifier
    Easy · python
    Solve Problem
  • Problem 2: Predict Probabilities
    Easy · python
    Solve Problem
  • Problem 3: Evaluate Predictions Against Actual Labels
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...