Now, let's create a function that trains a logistic regression model. This function needs to perform the following:
- Accept our FICO score data as an independent variable.
- Add an intercept to our model.
- Initialize and optimize the coefficients (or weights) of the logistic regression model.
- Return the optimized weights which define our trained model.
To optimize the coefficient/weights, we will use a technique called stochastic gradient descent. This technique will be covered in greater detail in the Appendix, Algorithms/Techniques Related to Machine Learning. For now, suffice it to say that we are trying to make predictions with some non-optimized weights, calculating an error for those ...