初始版本.

Signed-off-by: rick.chan <chenyang@autoai.com>
This commit is contained in:
rick.chan 2021-03-09 11:34:37 +08:00
parent 3f7ac330ab
commit a7479ffcae
2 changed files with 47 additions and 1 deletions

16
LinearBoston.py Normal file
View File

@ -0,0 +1,16 @@
#! /usr/bin/env python3
# -*- coding:utf-8 -*-
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
boston = load_boston()
x_train, x_test, y_train, y_test = train_test_split(boston.data, boston.target, test_size = 0.1, random_state = 42)
linear_reg = LinearRegression()
res = linear_reg.fit(x_train, y_train)
y_pred = linear_reg.predict(x_test)
print(y_pred)
print()
print(y_test)

View File

@ -1,3 +1,33 @@
# LinearBoston
使用线性回归预测 Boston 房价。
使用线性回归预测 Boston 房价。
基于 sklearn 机器学习框架。
## 1.安装依赖
```bash
pip3 install sklearn
```
## 2.使用
```bash
# Linux
$ ./LinearBoston.py
[29.3639579 36.18916482 14.05923305 24.76681233 18.79788306 23.24853399
17.67925163 13.52689687 23.47852891 20.64157306 25.09931716 18.95745403
-5.20884417 21.49578209 19.70582791 25.88188533 20.58810146 6.32255133
40.53496182 17.70625559 27.18358564 30.26489811 11.44273418 23.67928093
18.3134012 16.68382624 22.70408601 15.00807515 22.63999482 19.26595697
23.18874623 25.13865453 25.45744382 18.65563 17.14694386 17.09774591
30.86149933 20.30925718 23.6643961 24.16999127 14.02229608 32.76422241
42.75995463 17.52640822 27.33820148 17.4795262 14.37833428 25.34949499
20.51753419 30.15497476 21.71831626]
[23.6 32.4 13.6 22.8 16.1 20. 17.8 14. 19.6 16.8 21.5 18.9 7. 21.2
18.5 29.8 18.8 10.2 50. 14.1 25.2 29.1 12.7 22.4 14.2 13.8 20.3 14.9
21.7 18.3 23.1 23.8 15. 20.8 19.1 19.4 34.7 19.5 24.4 23.4 19.7 28.2
50. 17.4 22.6 15.1 13.1 24.2 19.9 24. 18.9]
```