# Scikit Learn
> 原文:[https://www.bookbookmark.ds100.org/ch/20/ref_sklearn.html](https://www.bookbookmark.ds100.org/ch/20/ref_sklearn.html)
```
# HIDDEN
# Clear previously defined variables
%reset -f
# Set directory for data loading to work properly
import os
os.chdir(os.path.expanduser('~/notebooks/20'))
```
## 型號和型號選擇
| 進口 | 功能 | 截面 | 說明 |
| --- | --- | --- | --- |
| `sklearn.model_selection` | [`train_test_split(*arrays, test_size=0.2)`](http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html) | 建模與估計 | 返回傳入的每個數組的兩個隨機子集,其中第一個子集中有 0.8 個數組,第二個子集中有 0.2 個數組 |
| `sklearn.linear_model` | [`LinearRegression()`](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) | Modeling and Estimation | 返回普通最小二乘線性回歸模型 |
| `sklearn.linear_model` | [`LassoCV()`](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) | Modeling and Estimation | 返回通過交叉驗證選擇最佳模型的 Lasso(L1 正則化)線性模型 |
| `sklearn.linear_model` | [`RidgeCV()`](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) | Modeling and Estimation | 返回一個脊線(L2 正則化)線性模型,并通過交叉驗證選擇最佳模型 |
| `sklearn.linear_model` | [`ElasticNetCV()`](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) | Modeling and Estimation | 返回 ElasticNet(l1 和 l2 正則化)線性模型,并通過交叉驗證選擇最佳模型 |
| `sklearn.linear_model` | [`LogisticRegression()`](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html) | Modeling and Estimation | 返回邏輯回歸分類器 |
| `sklearn.linear_model` | [`LogisticRegressionCV()`](http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegressionCV.html) | Modeling and Estimation | 返回通過交叉驗證選擇最佳模型的邏輯回歸分類器 |
## 使用模型[?](#Working-with-a-Model)
假設您有一個`model`變量是`scikit-learn`對象:
| Function | Section | Description |
| --- | --- | --- |
| `model.fit(X, y)` | Modeling and Estimation | 與傳入的 X 和 Y 匹配的模型 |
| `model.predict(X)` | Modeling and Estimation | 返回根據模型傳入的 x 的預測 |
| `model.score(X, y)` | Modeling and Estimation | 返回基于 corect 值(y)的 x 預測精度 |
- 一、數據科學的生命周期
- 二、數據生成
- 三、處理表格數據
- 四、數據清理
- 五、探索性數據分析
- 六、數據可視化
- Web 技術
- 超文本傳輸協議
- 處理文本
- python 字符串方法
- 正則表達式
- regex 和 python
- 關系數據庫和 SQL
- 關系模型
- SQL
- SQL 連接
- 建模與估計
- 模型
- 損失函數
- 絕對損失和 Huber 損失
- 梯度下降與數值優化
- 使用程序最小化損失
- 梯度下降
- 凸性
- 隨機梯度下降法
- 概率與泛化
- 隨機變量
- 期望和方差
- 風險
- 線性模型
- 預測小費金額
- 用梯度下降擬合線性模型
- 多元線性回歸
- 最小二乘-幾何透視
- 線性回歸案例研究
- 特征工程
- 沃爾瑪數據集
- 預測冰淇淋評級
- 偏方差權衡
- 風險和損失最小化
- 模型偏差和方差
- 交叉驗證
- 正規化
- 正則化直覺
- L2 正則化:嶺回歸
- L1 正則化:LASSO 回歸
- 分類
- 概率回歸
- Logistic 模型
- Logistic 模型的損失函數
- 使用邏輯回歸
- 經驗概率分布的近似
- 擬合 Logistic 模型
- 評估 Logistic 模型
- 多類分類
- 統計推斷
- 假設檢驗和置信區間
- 置換檢驗
- 線性回歸的自舉(真系數的推斷)
- 學生化自舉
- P-HACKING
- 向量空間回顧
- 參考表
- Pandas
- Seaborn
- Matplotlib
- Scikit Learn