<jupyter_start><jupyter_text>Method 1<jupyter_code>import pandas as pd
import statsmodels.formula.api as smf
import numpy as np<jupyter_output><empty_output><jupyter_text>predict the values of column A from the values in columns B and C<jupyter_code>df = pd.DataFrame({"A": [10,20,30,40,50], "B": [20, 30, 10, 40, 50], "C": [32, 234, 23, 23, 42523]})
df
result = smf.ols(formula="A ~ B + C", data=df).fit()
print(result.params)
print(result.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:                      A   R-squared:                       0.579
Model:                            OLS   Adj. R-squared:                  0.158
Method:                 Least Squares   F-statistic:                     1.375
Date:                Mon, 25 Nov 2019   Prob (F-statistic):              0.421
Time:                        07:05:27   Log-Likelihood:                -18.178
No. Observations:                   5   AIC:                             42.36
Df Residuals:                       2   BIC:                             41.19
Df Model:                           2                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|[...]<jupyter_text>Method 2<jupyter_code>from sklearn import linear_model

reg = linear_model.LinearRegression()
reg.fit(df[['B', 'C']], df['A'])

print(reg.coef_)
print(reg.intercept_)
## Example
import statsmodels.api as sm
dat = sm.datasets.get_rdataset("Guerry", "HistData").data
dat
results = smf.ols('Lottery ~ Literacy + np.log(Pop1831)', data=dat).fit()
results.params
print(results.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:                Lottery   R-squared:                       0.348
Model:                            OLS   Adj. R-squared:                  0.333
Method:                 Least Squares   F-statistic:                     22.20
Date:                Mon, 25 Nov 2019   Prob (F-statistic):           1.90e-08
Time:                        07:06:46   Log-Likelihood:                -379.82
No. Observations:                  86   AIC:                             765.6
Df Residuals:                      83   BIC:                             773.0
Df Model:                           2                                         
Covariance Type:            nonrobust                                         
===================================================================================
                      coef    std err          [...]
{'fraction_non_alphanumeric': 0.19343452170843628, 'fraction_numerical': 0.046240734204024005, 'mean_word_length': 1.3656093489148582, 'pattern_counts': {'":': 3, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '372993', 'license': 'MIT', 'n_tokens_mistral': 827, 'n_tokens_neox': 697, 'n_words': 173, 'path': 'OLS Regression Model.ipynb', 'repo_name': 'HussamCheema/pandas', 'size': '2833'}