提交 219b9b8d 编写于 作者: F feilong

add helloworld.md

上级 254d4749
# Hello World
HelloWorld, 请阅读如下代码:
```python
import numpy as np
def test():
X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
y = np.dot(X, np.array([1, 2])) + 3
// TODO(选择选项中的代码填充此处)
y_predict = reg.predict(np.array([[3, 5]]))
print(y_predict)
if __name__ == '__main__':
test()
```
若将以下选项中的代码分别填充到上述代码中**TODO**处,哪个选项不是线性模型?
## template
```java
import numpy as np
def test():
X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
y = np.dot(X, np.array([1, 2])) + 3
// 下面的 code 占位符会被替换成答案和选项代码
$code
y_predict = reg.predict(np.array([[3, 5]]))
print(y_predict)
if __name__ == '__main__':
test()
```
## 答案
```python
from sklearn import svm
reg = svm.SVC(kernel='rbf').fit(X, y)
```
## 选项
### 使用 LinearRegression
```python
from sklearn.linear_model import LinearRegression
reg = LinearRegression().fit(X, y)
```
### 使用岭回归
```python
from sklearn.linear_model import Ridge
reg = Ridge(alpha=0.1)
```
### 使用拉索算法
```python
from sklearn.linear_model import Lasso
reg = Lasso(alpha=0.1).fit(X, y)
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册