label1=dataset[dataset["Purchased"]==0]
label2=dataset[dataset["Purchased"]==1]
len_id_0=np.where(dataset.Purchased == 0) #indices for label 0
len_id_1=np.where(dataset.Purchased == 1)
x_1_0=label1["Age"] # 1st feature having label as 0
x_2_0=label1["EstimatedSalary"] # 2nd feature having label as 0
x_1_1=label2["Age"] # 1st features having label as 1
x_2_1=label2["EstimatedSalary"] # 2nd features having label as 1
plt.scatter(x_1_0,x_2_0)
plt.scatter(x_1_1,x_2_1)
plt.title('(Train set)')
plt.xlabel('Age')
plt.ylabel('Estimated Salary')
plt.show()
以下是绘制数据集值的代码,最初只是为了在图形上可视化数据集点:
包含描述边界的绘图
将“c”参数设置为目标变量
相关问题 更多 >
编程相关推荐