What you are looking for is a simple linear regression (which by the way is not an algorithm, but rather - data modeling approach, algorithms are used for finding the linear regression parameters, but regression itself is not an algorithm), yet you should also add the bias (intercept) term to your equation so it becomes:
S = w1*f1 + w2*f2 + w3*f3 + w4*f4 + b
or in the vectorized format
s = <F,W> + b
where <F,W>
is inner product of your weights and features, and b
is bias (real valued variable)
to unify, you can add a constant value f5=1, and include w5
instead of b, so it becomes
s = <F,W>
You can solve it using Ordinary Least Squares method
W = (F'F)^(-1)F's
which results in optimal linear regression in terms sum of squared residuals.
In each programming language you will find libraries for performing linear regression, so you do not have to implement it by yourself. In particular, libraries will also take care of introducing the b
variable, so there is no need to implement it by yourself.