import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LogisticRegression
df_train = pd.read_csv(r'E:\BaiduNetdiskDownload\Datasets\Breast-Cancer\breast-cancer-train.csv')#利用pandas读入数据
df_test =pd.read_csv(r'E:\BaiduNetdiskDownload\Datasets\Breast-Cancer\breast-cancer-test.csv')
#选取ClumpThickness与cell size作为特征,构建测试集中的正负分类样本
df_test_negative = df_test.loc[df_test['Type']==0][['Clump Thickness','Cell Size']]
df_test_positive = df_test.loc[df_test['Type']==1][['Clump Thickness','Cell Size']]
plt.scatter(df_test_negative['Clump Thickness'],df_test_negative['Cell Size'],marker='o',s=200,c='red')
plt.scatter(df_test_positive['Clump Thickness'],df_test_positive['Cell Size'],marker='x',s=150,c='black')
plt.xlabel('Clump Thickness')
plt.ylabel('Cell Size')
plt.show()
#利用numpy中的random函数随机采样直线的截距和系数
intercept =np.random.random([1])
coef =np.rando
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LogisticRegression
df_train = pd.read_csv(r'E:\BaiduNetdiskDownload\Datasets\Breast-Cancer\breast-cancer-train.csv')#利用pandas读入数据
df_test =pd.read_csv(r'E:\BaiduNetdiskDownload\Datasets\Breast-Cancer\breast-cancer-test.csv')
#选取ClumpThickness与cell size作为特征,构建测试集中的正负分类样本
df_test_negative = df_test.loc[df_test['Type']==0][['Clump Thickness','Cell Size']]
df_test_positive = df_test.loc[df_test['Type']==1][['Clump Thickness','Cell Size']]
plt.scatter(df_test_negative['Clump Thickness'],df_test_negative['Cell Size'],marker='o',s=200,c='red')
plt.scatter(df_test_positive['Clump Thickness'],df_test_positive['Cell Size'],marker='x',s=150,c='black')
plt.xlabel('Clump Thickness')
plt.ylabel('Cell Size')
plt.show()
#利用numpy中的random函数随机采样直线的截距和系数
intercept =np.random.random([1])
coef =np.rando