| 1234567891011121314151617181920212223242526272829303132 |
- # View more python learning tutorial on my Youtube and Youku channel!!!
- # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
- # Youku video tutorial: http://i.youku.com/pythontutorial
- """
- Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly.
- """
- from __future__ import print_function
- from sklearn import datasets
- from sklearn.linear_model import LinearRegression
- import matplotlib.pyplot as plt
- loaded_data = datasets.load_boston()
- data_X = loaded_data.data
- data_y = loaded_data.target
- model = LinearRegression()
- model.fit(data_X, data_y)
- print(model.predict(data_X[:4, :]))
- print(data_y[:4])
- X, y = datasets.make_regression(n_samples=100, n_features=1, n_targets=1, noise=10)
- plt.scatter(X, y)
- plt.show()
|