def fetch_load_letters(data_dir=None):
path = os.path.join(get_data_home(data_dir), 'letter-recognition.data')
if not os.path.exists(path):
from urllib import request
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/letter-recognition/letter-recognition.data'
print('Downloading letter-recognition dataset from {}...'.format(url))
request.urlretrieve(url=url, filename=path)
else:
print('Found letter-recognition in {}!'.format(path))
X, y = [], []
with open(path) as f:
reader = csv.reader(f)
for row in reader:
y.append(row[0])
X.append(row[1:])
labels, label_idx = np.unique(y, return_inverse=True)
return np.asarray(X, dtype=float), label_idx
评论列表
文章目录