Two Causes
df has columns price, size and age. Fit price on both size and age with a statsmodels formula and return the fitted parameters as a dict with the keys Intercept, size and age.
Example 1
df {"size":[1,2,3,4,5],"age":[5,3,4,1,2],"price":[8,16,19,30,33]}
returns {"Intercept":12.199999999999935,"size":4.888888888888898,"age":-1.8888888888888804}
Example 2
df {"size":[0,1,0,1,2],"age":[0,0,1,1,2],"price":[1,3,6,8,15]}
returns {"Intercept":1.0,"size":2.0,"age":5.0}
The prices follow 1 + 2 * size + 5 * age exactly.
Constraints
5 <= len(df) <= 40
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Better of Two ModelsMedium
- Chance of YesMedium
- Does One Change the OtherMedium
- Model for CountsMedium
- Odds of YesMedium
- Pattern in the LeftoversMedium
- Point That Pulls HardestMedium
- Tangled PredictorsMedium