python基础语法——2 综合基础案例之乳腺癌肿瘤预测代码

import pandas
# 训练集
train = pandas.read_csv("c://train.csv")
# 测试集
test = pandas.read_csv("c://test.csv")
# 选取‘Clump Thickness’与‘Cell Size'作为特征,构建测试集中的正负分类样本
test_negative = test.loc[test['Type'] == 0][['Clump Thickness', 'Cell Size']]
test_positive = test.loc[test['Type'] == 1][['Clump Thickness', 'Cell Size']]

import matplotlib.pyplot as plt

# 绘制良性肿瘤样本点,标记为红色
plt.scatter(test_negative['Clump Thickness'], test_negative['Cell Size'], marker='o', s=200, c='red')

# 绘制恶性肿瘤样本点,标记为黑色
plt.scatter(test_positive['Clump Thickness'], test_positive['Cell Size'], marker='x', s=150, c='black')

# 绘制x,y轴
plt.xlabel('Clump Thickness')
plt.ylabel('Cell Size')

import numpy as np
# 利用numpy中random函数随机采样直线的截距和系数
intercept = np.random.random([1])
coef = np.random.random([2])
lx = np.arange(0, 12)
ly = (-intercept-lx*coef[0])/coef[1]

# 绘制一条随机直线
plt.plot(lx, ly, c='yellow')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值