How to get the best parameters in a linear regression for best fitted line

Dear All,
Glad to be learning ML and when i tried what was been taught on a large dataset, i visualized my predicted and actual and i’m getting this for a linear regression.
Seems choosing of my parameters is bad. Any contribution to this?

You need to plot your data without the connecting lines.

Note that you don’t “choose the parameters”. The parameters (the weights and bias) are learned through training.

You are plotting the data w.rt x_train, but your predicted values have been calculated with x, inside the compute_model function