Implementation of Simple Linear Regression Algorithm Using Python
Implementation of Simple Linear Regression Algorithm Using Python
Out[2]:
Id SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species
In [3]: Thomas_df.columns
In [4]: Thomas_df.head()
Out[4]:
Id SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species
In [5]: Thomas_df.tail()
Out[5]:
Id SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species
shape
In [6]: Thomas_df.shape
Out[6]: (150, 6)
In [8]: x
Out[8]:
SepalWidthCm PetalLengthCm PetalWidthCm
In [9]: y
Out[9]: 0 5.1
1 4.9
2 4.7
3 4.6
4 5.0
...
145 6.7
146 6.3
147 6.5
148 6.2
149 5.9
Name: SepalLengthCm, Length: 150, dtype: float64
Split dataset
In [12]: x_train
Out[12]:
SepalWidthCm PetalLengthCm PetalWidthCm
In [13]: x_test
Out[13]:
SepalWidthCm PetalLengthCm PetalWidthCm
In [14]: y_train
Out[14]: 69 5.6
135 7.7
56 6.3
80 5.5
123 6.3
...
9 4.9
103 6.3
67 5.8
117 7.7
47 4.6
Name: SepalLengthCm, Length: 100, dtype: float64
In [15]: y_test
Out[17]: ▾ LinearRegression
LinearRegression()
In [19]: y_pred
In [20]: x_pred
In [ ]: