Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to fit a logistic regression model manually using gradient descent.

Hard

Problem Statement

Write a function to fit a logistic regression model manually using gradient descent.

Sample Input

Data Frame: 
 x y 
1 1 0 
2 2 0 
3 3 1 
4 4 1

Sample Output

Fitted Coefficients: -5.6964 2.3867 

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
logistic_regression <- function(df, lr, iterations) { # Your logic here } # Call the function
Log in or sign up to run or submit your code.Log inSign up
Input
Data Frame: 
 x y 
1 1 0 
2 2 0 
3 3 1 
4 4 1
Expected Output
Fitted Coefficients: -5.6964 2.3867