小编Fra*_*n04的帖子

字典数据可以随机分成测试集和训练集吗?

我想了解我是否有一组 JSON 格式的字典数据,如下例所示:

data = {'a':'120120121',
'b':'12301101',
'c':'120120121',
'd':'12301101',
'e':'120120121',
'f':'12301101',
'g':'120120121',
'h':'12301101',
'i':'120120121',
'j':'12301101'}
Run Code Online (Sandbox Code Playgroud)

是否可以使用 Python 将字典随机拆分为 70:30?

输出应该是这样的:

training_data = {'a':'120120121',
    'b':'12301101',
    'c':'120120121',
    'e':'120120121',
    'g':'120120121',
    'i':'120120121',
    'j':'12301101'}

test_data = {'d':'12301101',
    'f':'12301101',
    'h':'12301101'}
Run Code Online (Sandbox Code Playgroud)

python dictionary

1
推荐指数
1
解决办法
497
查看次数

标签 统计

dictionary ×1

python ×1