当前位置:网站首页>随机森林以及 AMR 训练出的诗词制造器
随机森林以及 AMR 训练出的诗词制造器
2022-06-28 10:54:00 【NikoDos】
AMR 即 Artificial mental retardation(即人工智障),是一种新兴的机器学习算法,旨在将最好的数据同通过百般蹂躏,变成一堆垃圾,下面将指导读者如何使用这种算法。
# 案例 诗词制造器
此案例较为简单,只需要运用到随机森林和 AMR 技术即可,难度在于有没有熟练掌握,贴源码。
import random
typ = input("请输入选择: 1.五言 2.七言")
data = [
'垂杨',
'新柳',
'玉丝纶',
'金嫩',
'柔条',
'曲岸垂杨',
'柳丝',
'闲柳',
'千花万柳',
'花海',
'芳甸吐嫩',
'摇绿',
'绿卷',
'浓翠',
'横翠',
'金碧',
'舒卷款款',
'片片',
'缕缕',
'落纷纷新晴',
'笼晴',
'韶光',
'婉媚',
'温丽',
'芊绵',
'春华',
'空灵',
'春柔',
'清婉',
'馨烈',
'和婉',
'清蕊',
'清芬',
'素约',
'红素',
'旖旎飞花',
'浮花',
'落英',
'花影',
'芳丛',
'浮香',
'锦花',
'绣草',
'烂漫',
'芳踪',
'镂玉',
'雕琼',
'繁枝',
'素景',
'密叶',
'稠花点水',
'扑面',
'风轻',
'水胧',
'倚暖胭脂色',
'水溶溶',
'不留痕',
'几点春',
'邀春驻',
'花映柳',
'花深浅',
'树高低',
'翻微风',
'香接天浓露飘香',
'软软东风',
'水逝云卷',
'繁花盈枝',
'百卉团团',
'和风轻暖',
'春光满树',
'秀色灼灼',
'红尘倦客',
'柳带摇风',
'香坠庭户',
'水阔花飞',
'瘦叶和风',
'叶叶心心',
'眼迷魂牵',
'浅粉深红',
]
def choose_word(num):
chose = []
for i in range(num):
chose.append(random.choice(data))
return chose
if int(typ) == 1:
sentence_list = []
for i in range(10):
chose = choose_word(2)
while len(chose[-1]) + len(chose[-2]) != 5:
chose = choose_word(2)
if len(chose[-1]) == 2 and len(chose[-2]) == 3:
sentence_list.append(chose[-1] + chose[-2])
elif len(chose[-1]) == 3 and len(chose[-2]) == 2:
sentence_list.append(chose[-2] + chose[-1])
print(sentence_list)
elif int(typ) == 2:
sentence_list = []
for i in range(10):
chose = choose_word(3)
while len(chose[-1]) + len(chose[-2]) != 7:
chose = choose_word(3)
sentence_list.append(chose[-1] + chose[-2])
print(sentence_list)
131 行代码,数据就占了一大半,这证明数据的庞大,考验了你的编码速度以及耐心。 下面的逻辑处理,使用了随机森林 random 高级库。
random.choice(list)此代码就是为了随机森林训练数据集,AMR 就体现于代码编写的愚蠢以及运行结果的 rubbish。
此算法的时间复杂度为 O (2^n),生成的诗皆为烂诗,为精品也。是 AMR 测试的好样本,随机森林的好榜样!
边栏推荐
猜你喜欢
随机推荐
June training (day 28) - Dynamic Planning
DlhSoft Kanban Library for WPF
Does flink1.15 support MySQL views? I configured the view name at the table name to save, but the table could not be found. Think
Metersphere实现UI自动化元素不可点击(部分遮挡)
ruoyi集成积木报表(nice)
Installing MySQL database (CentOS) in Linux source code
[cloud resident co creation] detailed introduction to DWS alarm service DMS and cluster connection mode
毕业季 新的开始
Secretary of the Ukrainian national security and National Defense Commission: will carry out precision strikes against targets in Russia
MySQL (II)
JSON模块、hashlib、base64
etf持仓如何影响现货金价?
方法重写(Override)
[Agora] get an Agora_ Example usage of refptr object
Docker modifies the user name and password of MySQL
Katalon全局变量在TestObject引用
[practice] appium settings app is not running after 5000ms
Metersphere uses JS to refresh the current page
[QT] connect syntax reference implementation
Fastposter v2.8.4 release e-commerce poster generator








