FunctionRacerProblemsRace

Odds of Yes

MediumstatsmodelsPython

Each y[i] is 0 or 1 (no or yes), and x[i] is a measurement that may sway it. Fit a logistic regression of y on x with an intercept and return [intercept, slope]. Answers within 0.01% are accepted.

Example 1

x [-3,-2,-2,-1,-1,0,0,1,1,2,2,3,-1.5,0.5,1.5]
y [0,0,0,0,1,0,1,1,0,1,1,1,0,1,1]
returns [0.1815478429461524,1.3287569246438977]

Yes becomes more likely as x grows, so the slope is positive.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More statsmodels problems