import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression#从sklearn导入逻辑回归算法
train=pd.read_csv('./data/breast_cancer_train.csv')#读取csv数据
test=pd.read_csv('./data/breast-cancer-test.csv')#读取csv数据
print(train)
print(test)
train_data = np.array(train)#将数据做成数组形式
test_data = np.array(test)#将数据做成数值形式
print(train_data)
print(test_data)
X_train = train_data[:,1:3] # 取第1,2列作为特征
y_train = train_data[:,3] # 取第3列为标签
X_test = test_data[:,1:3]#取第1,2列作为特征
y_test = test_data[:,3]#取第3列作为标签
p_index = np.where(train_data[:,3]==1)[0] # 取出所以正样本的索引
n_index = np.where(train_data[:,3]==0)[0] # 取出所以负样本的索引
positive = X_train[p_index,:] # 取出所以正样本
nagative = X_train[n_index,:] # 取出所以负样本
plt.scatter(nagative[:,0],nagative[:,1],marker='o',s=200,c='red') #绘制样本点
plt.scatter(positive[:,0],positive[:
pandas学习实例
最新推荐文章于 2022-08-10 16:23:42 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)