2018-12-16
阅读量:
995
SVM中怎么导入数据?
导入数据集
这是支持向量机的直觉,它优化了表示数据集之间垂直距离的线性判别模型。现在让我们使用我们的训练数据训练分类器。在训练之前,我们需要将癌症数据集导入为csv文件,我们将在其中训练所有功能中的两个功能。
# importing required libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# reading csv file and extracting class column to y.
x = pd.read_csv("C:\...\cancer.csv")
a = np.array(x)
y = a[:,30] # classes having 0 and 1
# extracting two features
x = np.column_stack((x.malignant,x.benign))
x.shape # 569 samples and 2 features
print (x),(y)






评论(0)


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