python 分开火车和测试apc-od
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 分开火车和测试apc-od相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import shutil
import os.path as osp
from sklearn.cross_validation import train_test_split
from sklearn.datasets import load_files
dataset = load_files('dataset', load_content=False, shuffle=False)
files = dataset.filenames
y = dataset.target
file_train, file_test, y_train, y_test = train_test_split(files, y, test_size=0.2)
for file_, label in zip(file_train, y_train):
to_file = osp.join('train', dataset.target_names[label], osp.basename(file_))
print file_, '->', to_file
shutil.move(file_, to_file)
for file_, label in zip(file_test, y_test):
to_file = osp.join('test', dataset.target_names[label], osp.basename(file_))
print file_, '->', to_file
shutil.move(file_, to_file)
以上是关于python 分开火车和测试apc-od的主要内容,如果未能解决你的问题,请参考以下文章
我错过了 ggplot 中的第二行,应该有测试和火车线吗?
学习python的第一个小目标:通过requests+xlrd实现简单接口测试,将测试用例维护在表格中,与脚本分开。
python爬虫学习之用Python抢火车票的简单小程序
当我的测试集包含我的火车数据没有的数据时出现错误?
火花火车测试拆分
[Python爬虫]使用Selenium操作浏览器订购火车票