Hi Eugen,

You should be able to do this without the LinearRegression API. I believe
for a linear regression model (
https://en.wikipedia.org/wiki/Simple_linear_regression)
[image: image.png]
the best estimator for the intercept will be
[image: image.png]
where \overline{y} is the average of the target variable and \overline{x}
is the average of the features in your new training data. \hat{\beta} will
remain your previously fit slope. This lets you fit a new intercept
(\alpha) given the previous slope (\beta) and the averages of your new
training data, which you should be able to compute in a straightforward
manner using Spark.

I imagine there might be a way to do this with the LinearRegression API
though.

Thanks,
Steven


On Sat, Mar 21, 2020 at 12:49 AM <eugen.wintersber...@gmail.com> wrote:

> Hi,
> I was wondering if it would be possible to fit only the intercept on a
> LinearRegression instance by providing a known coefficient?
>
> Here is some background information: we have a problem where linear
> regression is well suited as a predictor. However, the model requires
> continuous adoption. During an initial training, the coefficient and the
> intercept of the linear model are determined from a given set of training
> data. Later, this model requires adoption during which the intercept has to
> be adopted to a new set of training data (the coefficient, in other words
> the slope, remains the same as obtained from the initial model).
>
> I had a look on the Java API for LinearRegression and could not find a way
> how to only fit the intercept and set initial parameters for a fit. Am I
> missing something? Is there a way how to to do this with the
> LinearRegression class in Sparks' ML package or do I have to use a
> different approach?
>
> Thanks in advance.
>
> regards
> Eugen
>
>

Reply via email to