FunctionRacerProblemsRace

Chance of Yes

MediumstatsmodelsPython

Whether a customer buys (1) or walks away (0) depends on the price shown. x holds the prices of past cases and y what happened. Model the outcome with a logistic regression that has an intercept, and return the chance of a 1 at the price new_x. 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]
new_x 0.0
returns 0.5452627088378293

Around x = 0 the two answers are about equally common in this data.

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