Problem 4: Apply a Custom Decision Threshold
Easypython
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
textX=[[1],[2],[7],[8]], y=[0,0,1,1], new=[[4]], threshold=0.3
Example Output
textProbability: 0.45 Prediction with 0.3 threshold: 1
Concepts Covered
.predict_proba(), custom threshold logic, conditionals.