标签:das pre csv arc http lib style and raw
入门机器学习时,一些测试数据是网络上的csv文件。这里总结了两种加载csv文件的方式:
import numpy as np import urllib2 url = "http://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data" raw_data = urllib2.urlopen(url) dataset = np.loadtxt(raw_data, delimiter=",") X = dataset[:, 0:7] y = dataset[:, 8]
import pandas as pd
url = "http://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data" dataFrame = pd.read_csv(url, header=None) dataset = dataFrame.values X = dataset[:, 0:7] y = dataset[:, 8]
标签:das pre csv arc http lib style and raw
原文地址:http://www.cnblogs.com/zc9527/p/6286621.html