DocumentClassifier
概述
DocumentClassifier是一个Swift框架,可以将文档分类到五个类别之一(商业、娱乐、政治、体育和技术)。它使用与BBC的1500篇新闻文章训练的CoreML模型。
功能
- iOS 11.0+、macOS 10.13+、tvOS 11.0+、watchOS 4.0+
- 100% 测试覆盖率
- 最佳CV得分:0.965333333333
用法
let text = articleText
guard let classification = classifier.classify(text) else { return }
print(classification.prediction) // Technology: 0.42115752953489294
print(classification.allResults) // Business: 0.141, Entertainment: 0.138, Politics: 0.113, Sports: 0.187, Technology: 0.421
安装
CocoaPods
CocoaPods 是 Cocoa 项目的集中式依赖管理器。要使用 CocoaPods 安装 DocumentClassifier
-
请确保已安装最新版本的 CocoaPods。安装指南。
-
将 DocumentClassifier 添加到您的 Podfile
use_frameworks!
pod 'DocumentClassifier', '1.2.0'
- 运行
pod install
命令。
示例应用
NewsClassifier 是使用该框架的示例应用。
模型
- 模型链接
- 最佳CV得分:0.965333333333
- 使用 2004-2005 年间来自 BBC 的 1,500 篇新闻文章进行训练(见参考文献)
- 使用 scikit-learn Pipeline 通过 coremltools 转换。
- 基于 LinearSVC 分类器。
作者
Todd Kramer,[email protected]
参考文献
- BBC 数据集
- D. Greene 和 P. Cunningham. "解决核文档聚类的对角优势问题的实用方法", ICML 2006. 链接
- Vadym Markov,SentimentPolarity
- 优秀的 Core ML 模型
- scikit-learn
- 苹果机器学习
- CoreML 框架
- coremltools