2019-02-15
阅读量:
642
搭建模型如何加载数据集
数据集通常有两个主要组件:
- 特征 :(也称为预测变量,输入或属性)它们只是我们数据的变量。它们可以不止一个,因此由特征矩阵表示('X'是表示特征矩阵的常用符号)。所有功能名称的列表称为功能名称。
- 响应 :(也称为目标,标签或输出)这是输出变量,具体取决于特征变量。我们通常有一个响应列,它由响应向量表示('y'是表示响应向量的常用符号)。响应向量采用的所有可能值称为目标名称。
加载示例数据集: scikit-learn附带了一些示例数据集,例如用于分类的虹膜和数字数据集以及用于回归的波士顿房价数据集。
下面给出了一个如何加载示例数据集的示例:
# load the iris dataset as an example
from sklearn.datasets import load_iris
iris = load_iris()
# store the feature matrix (X) and response vector (y)
X = iris.data
y = iris.target
# store the feature and target names
feature_names = iris.feature_names
target_names = iris.target_names
# printing features and target names of our dataset
print("Feature names:", feature_names)
print("Target names:", target_names)
# X and y are numpy arrays
print("\nType of X is:", type(X))
# printing first 5 input rows
print("\nFirst 5 rows of X:\n", X[:5])






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论