Professional Documents
Culture Documents
Regressao Linear Multipla - Ipynb - Colaboratory
Regressao Linear Multipla - Ipynb - Colaboratory
ipynb - Colaboratory
1 import pandas as pd
2 import statsmodels.formula.api as smf
3 import seaborn as sn
1 propaganda = [1,2,3,4,5]
2 vendas = [1,2,4,5,8]
3 demanda = [12,15,16,17,19]
4 df = pd.DataFrame(list(zip(propaganda,vendas,demanda)),
5 columns = ['propaganda','vendas','demanda'])
6 df
0 1 1 12
1 2 2 15
2 3 4 16
3 4 5 17
4 5 8 19
1 df.corr(method ='pearson')
1 correlation = df.corr(method ='pearson')
2 plot = sn.heatmap(correlation, annot = True, fmt=".4f", linewidths=.6)
3 plot
<matplotlib.axes._subplots.AxesSubplot at 0x7f8af4143950>
https://colab.research.google.com/drive/1brMaelvpTlP6hrc5YhJSvKOLi44-Lbv0#scrollTo=0Rm5NVr4Ukrr&printMode=true 1/2
12/03/2022 10:42 regressao_linear_multipla.ipynb - Colaboratory
1
model = smf.ols(formula='vendas ~ propaganda + demanda', data=df)
2
resultado = model.fit()
3
print(resultado.summary())
Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correc
/usr/local/lib/python3.7/dist-packages/statsmodels/stats/stattools.py:71: Val
"samples were given." % int(n), ValueWarning)
https://colab.research.google.com/drive/1brMaelvpTlP6hrc5YhJSvKOLi44-Lbv0#scrollTo=0Rm5NVr4Ukrr&printMode=true 2/2