In the previous chapter related to unsupervised learning, we have learnt about several Python packages. Fortunately, these packages can be applied to supervised learning algorithms as well. The following example is for a linear regression by using a few Python datasets. The Python dataset can be downloaded from the author's website at http://www.canisius.edu/~yany/python/ffcMonthly.pkl. Assume that the data is saved under c:/temp/:
import pandas as pd x=pd.read_pickle("c:/temp/ffcMonthly.pkl") print(x.head()) print(x.tail())
The output is shown here:

We plan to run a linear regression; see the formula here:
Here, Ri is stock i's returns, Rmkt is the market returns, RSMB is the portfolio returns of small stocks minus the portfolio returns of big stocks, RHML is the portfolio returns with high book-to-market ratio (of equity...