import pandas as pd
import numpy as np
#使用pandas读入并简单处理csv数据
column_names=['Sample code number', 'Clump Thickness', 'Uniformity of \
Cell Size', 'Uniformity of Cell shape', 'Marginal Adhesion', 'Single \
Epithelial Cell Size', 'Bare Nuclei', 'Bland Chromatin', 'Normal Nuvleoli',
'Mitoses', 'Class']
data=pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer- wisconsin/breast-cancer-wisconsin.data', \
names=column_names)
data=data.replace(to_replace='?', value=np.nan)
data=data.dropna(how='any')
data.shape
#准备训练、测试数据
from sklearn.cross_validation import train_test_split
x_train, x_test, y_train, y_test=train_test_split(data[colum_names[1:\
10]], data[column_names[10]], test_size=0.25, random_state=33)
y_train.value_counts()
使用panads处理数据
最新推荐文章于 2024-08-23 09:48:05 发布