1
$\begingroup$

I have some data $(x_{1},y_{1}), (x_{2},y_{2}), ..., (x_{n},y_{n})$, where both $x$ and $y$ represent real numbers (float). I want use Scikit-learns LinearRegression model to fit a model of the form:

$y_{i} = b_{0} + b_{1}x_i + e_{i} $

Typically, I know that OLS is used to compute the parameters $b_{0}, b_{1}$. However, in my case, I happen to know that $b_{1}=c$ so I only want to fit $b_{0}$. Is there a way to force scikit-learn to use $b_{1}=c$ as the slope ratio and only estimate the intecept $b_0$, or is a custom class necessary?

$\endgroup$
2
$\begingroup$

You can just compute: $\hat{b}_0 = \operatorname{mean}(y-cx)$

$\endgroup$
1
  • $\begingroup$ just for understanding, what is meant by "fixed" slope and parameter here ? $\endgroup$ Mar 6 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.