技术宅的结界

 找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 352|回复: 0
收起左侧

机器学习&深度学习案例展示

[复制链接]

266

主题

438

帖子

4589

积分

用户组: 真·技术宅

UID
2
精华
61
威望
147 点
宅币
3427 个
贡献
125 次
宅之契约
0 份
在线时间
592 小时
注册时间
2014-1-25
发表于 2017-10-21 18:25:53 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有帐号?立即注册→加入我们

x
1.情感分析

分析一段话的感情色彩是乐观的,还是消极的
[Python] 纯文本查看 复制代码
import Algorithmia

def print_sentiment(phrase):
    input = {
      "document": phrase,
      "language":"auto"
    }
    client = Algorithmia.client('simZVCjjKPPXZBthxtGBQ8GyYpY1')
    algo = client.algo('nlp/SentimentAnalysis/1.0.4')
    sentiment = algo.pipe(input).result[0]["sentiment"]
    if sentiment > 0:
        print("positive sentiment")
    else:
        print("negative sentiment")
        
print_sentiment("I really like Algorithmia!")
print_sentiment("I really don't like Algorithmia!")
print_sentiment("Algorithmia'yi cok seviyorum.")
print_sentiment("Je déteste les grenouilles")


positive sentiment
negative sentiment
positive sentiment
negative sentiment

也可以获取更详细的信息:
    client = Algorithmia.client('simZVCjjKPPXZBthxtGBQ8GyYpY1')
    algo = client.algo('nlp/SocialSentimentAnalysis/0.1.4')
    print(algo.pipe(input).result)

[{'compound': 0.474, 'negative': 0, 'neutral': 0.393, 'positive': 0.607, 'sentence': 'I really like Algorithmia!'}]
[{'compound': -0.398, 'negative': 0.472, 'neutral': 0.528, 'positive': 0, 'sentence': "I really don't like Algorithmia!"}]


2.语义概括
从一大段文字中进行概括总结

[Python] 纯文本查看 复制代码
import Algorithmia

input = "In the history of artificial intelligence, an AI winter is a period of reduced funding and interest in artificial intelligence research. The term was coined by analogy to the idea of a nuclear winter. The field has experienced several hype cycles, followed by disappointment and criticism, followed by funding cuts, followed by renewed interest years or decades later. The term first appeared in 1984 as the topic of a public debate at the annual meeting of AAAI (then called the \"American Association of Artificial Intelligence\"). It is a chain reaction that begins with pessimism in the AI community, followed by pessimism in the press, followed by a severe cutback in funding, followed by the end of serious research. At the meeting, Roger Schank and Marvin Minsky—two leading AI researchers who had survived the \"winter\" of the 1970s—warned the business community that enthusiasm for AI had spiraled out of control in the '80s and that disappointment would certainly follow. Three years later, the billion-dollar AI industry began to collapse. Hypes are common in many emerging technologies, such as the railway mania or the dot-com bubble. An AI winter is primarily a collapse in the perception of AI by government bureaucrats and venture capitalists. Despite the rise and fall of AI's reputation, it has continued to develop new and successful technologies. AI researcher Rodney Brooks would complain in 2002 that \"there's this stupid myth out there that AI has failed, but AI is around you every second of the day.\" In 2005, Ray Kurzweil agreed: \"Many observers still think that the AI winter was the end of the story and that nothing since has come of the AI field. Yet today many thousands of AI applications are deeply embedded in the infrastructure of every industry.\" He added: \"the AI winter is long since over.\""
client = Algorithmia.client('simZVCjjKPPXZBthxtGBQ8GyYpY1')
algo = client.algo('nlp/Summarizer/0.1.6')
print(algo.pipe(input).result)


In the history of artificial intelligence, an AI winter is a period of reduced funding and interest in artificial intelligence research. The term was coined by analogy to the idea of a nuclear winter. The field has experienced several hype cycles, followed by disappointment and criticism, followed by funding cuts, followed by renewed interest years or decades later.

3.编程语言检测
输入一段代码,分析编程语言类型
[Python] 纯文本查看 复制代码
import Algorithmia

input = "/* Simple JavaScript example */\n\n// add two numbers\nfunction add(n, m) {\n  return n + m;\n}"
client = Algorithmia.client('simZVCjjKPPXZBthxtGBQ8GyYpY1')
algo = client.algo('PetiteProgrammer/ProgrammingLanguageIdentification/0.1.3')

algo.pipe(input).result


[['javascript', 0.9898891716577288],
['markdown', 0.003837364611352919],
['java', 0.0018736157456299355],
['php', 0.001753187646371167],
['c', 0.0009585207454160036],
['lua', 0.0007419186073970403],
['html', 0.00035180268743055217],
['objective-c', 0.00027798425161126557],
['sql', 0.0001728341808434431],
['css', 3.861177400551988e-05],
['c++', 3.439039144376966e-05],
['swift', 3.122888156291083e-05],
['bash', 1.3677125153852449e-05],
['ruby', 1.2247314781813987e-05],
['perl', 5.5816600359435255e-06],
['c#', 3.8442524620865984e-06],
['scala', 3.723956933340268e-06],
['python', 1.5721135605950836e-07],
['r', 6.431838326426007e-08],
['haskell', 4.036764786336714e-08],
['vb', 3.261245241114874e-08]]

4.python语句预测
[Python] 纯文本查看 复制代码
import Algorithmia

input = {"code": "from __future__ import", "num_results": 5}
client = Algorithmia.client('simZVCjjKPPXZBthxtGBQ8GyYpY1')
algo = client.algo('PetiteProgrammer/pythoncodeprediction/1.0.4')


[['absolute_import', 0.4474910795688629],
['unicode_literals', 0.2473190277814865],
['(', 0.197650209069252],
['print_function', 0.0650412067770958],
['division', 0.03176164627075195]]

[Python] 纯文本查看 复制代码
import Algorithmia

input = {"code": "for i in", "num_results": 5}
client = Algorithmia.client('simZVCjjKPPXZBthxtGBQ8GyYpY1')
algo = client.algo('PetiteProgrammer/pythoncodeprediction/1.0.4')
algo.pipe(input).result


[['range', 0.6257643103599548],
['<UNK>', 0.1413002461194992],
['xrange', 0.05714259296655655],
['self', 0.02985670417547226],
['(', 0.022345777601003647]]

以上这写代码都出自算法市场https://algorithmia.com/,在未来,算法也可以像App一样推广

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|技术宅的结界 ( 滇ICP备16008837号|网站地图

GMT+8, 2018-9-24 07:47 , Processed in 0.090813 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表