| 123456789101112131415161718192021222324 |
- # 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
- 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(model.coef_)
- print(model.intercept_)
- print(model.get_params())
- print(model.score(data_X, data_y)) # R^2 coefficient of determination
|