Skip to content
CampusEduX

Problem 1: Train a Basic Logistic Regression Classifier

Easypython
Learn the Concept: Logistic Regression

Problem Description

Write a Python program that trains a Logistic Regression model to predict pass/fail based on hours studied, then predicts the class for 2 new students.

Input

Training data (hours studied and pass/fail labels), and 2 new hour values.

Output

The predicted class labels for the 2 new students.

Constraints

  • At least 6 labeled training examples.

Example Input

text
hours = [[1],[2],[3],[7],[8],[9]], labels=[0,0,0,1,1,1], new=[[4],[8.5]]

Example Output

text
Predictions: [0 1]

Concepts Covered

LogisticRegression, .fit(), .predict().

Related Problems

  • Problem 2: Predict Probabilities
    Easy · python
    Solve Problem
  • Problem 3: Evaluate Predictions Against Actual Labels
    Easy · python
    Solve Problem
  • Problem 4: Apply a Custom Decision Threshold
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...