Data Science From Scratch To Production MVP Style: Model

This post is a part of the Data Science From Scratch To Production MVP Style series.

Now this section is of least important so we’re going to be incredibly sloppy here. We’ll perform a simple train test split and create a simple Linear Regression model.

1
2
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20)
model = LinearRegression().fit(X_train, y_train)
1
model.score(X_test, y_test)

0.498875410976377

1
model.coef_

array([635.1964214])

1
model.intercept_

5810.549007860056

1
2
3
4
5
6
pyplot.scatter(X_test, y_test, color = 'red')
pyplot.plot(X_train, model.predict(X_train), color = 'blue')
pyplot.title('temperature_fahrenheight vs ice_cream_sales_usd (Test set)')
pyplot.xlabel('temperature_fahrenheight')
pyplot.ylabel('ice_cream_sales_usd')
pyplot.show()

linear regression fit

While our model isn’t great, lets pretend we’re satisfied with it and move on to preparing to wrap our model in an API and getting it into production.


This is a post in the Data Science From Scratch To Production MVP Style series.
Other posts in this series: