W14 作业

import random
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import statsmodels.api as sm
import statsmodels.formula.api as smf

sns.set_context("talk")
anascombe = pd.read_csv('anscombe.csv')
anascombe.head()

print(anascombe.groupby('dataset')['x'].mean())
print(anascombe.groupby('dataset')['x'].var())
print(anascombe.groupby('dataset')['y'].mean())
print(anascombe.groupby('dataset')['y'].var())
print(anascombe.groupby('dataset').corr())
x = sm.add_constant(x)
L = sm.OLS(x,y)
print(L.fit().summary())

g = sns.FacetGrid(anascombe, col='dataset', size=5)
g = g.map(plt.scatter, "x", "y")
plt.show()


你可能感兴趣的:(作业,作业)