In [1]:
import seaborn as sns
iris = sns.load_dataset("iris")
iris.head()


Out[1]:
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa

In [2]:
%matplotlib inline
import seaborn as sns; sns.set()
sns.pairplot(iris, hue="species", size = 1.5);


This is a header


In [3]:
X_iris = iris.drop("species", axis=1)
X_iris.shape


Out[3]:
(150, 4)

In [4]:
y_iris = iris['species']
y_iris.shape


Out[4]:
(150,)

Sci kit learn's Estimator Api


In [5]:
import matplotlib.pyplot as plt
import numpy as np

rng = np.random.RandomState(42)
x = 10*rng.rand(50)
y = 2*x-1+rng.randn(50)
plt.scatter(x,y)


Out[5]:
<matplotlib.collections.PathCollection at 0x7f6dbc5320d0>

In [7]:
from sklearn.linear_model import LinearRegression
model = LinearRegression(fit_intercept=True)
model


Out[7]:
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)

In [15]:
X = x[:, np.newaxis]
X.shape


Out[15]:
(50, 1)

In [16]:
model.fit(X,y)


Out[16]:
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)

In [ ]:


In [ ]: