- Machine Learning for Cybersecurity Cookbook
- Emmanuel Tsukerman
- 268字
- 2021-06-24 12:29:00
Natural language processing using a hashing vectorizer and tf-idf with scikit-learn
We often find in data science that the objects we wish to analyze are textual. For example, they might be tweets, articles, or network logs. Since our algorithms require numerical inputs, we must find a way to convert such text into numerical features. To this end, we utilize a sequence of techniques.
A token is a unit of text. For example, we may specify that our tokens are words, sentences, or characters. A count vectorizer takes textual input and then outputs a vector consisting of the counts of the textual tokens. A hashing vectorizer is a variation on the count vectorizer that sets out to be faster and more scalable, at the cost of interpretability and hashing collisions. Though it can be useful, just having the counts of the words appearing in a document corpus can be misleading. The reason is that, often, unimportant words, such as the and a (known as stop words) have a high frequency of occurrence, and hence little informative content. For reasons such as this, we often give words different weights to offset this. The main technique for doing so is tf-idf, which stands for Term-Frequency, Inverse-Document-Frequency. The main idea is that we account for the number of times a term occurs, but discount it by the number of documents it occurs in.
In cybersecurity, text data is omnipresent; event logs, conversational transcripts, and lists of function names are just a few examples. Consequently, it is essential to be able to work with such data, something you'll learn in this recipe.
- 嵌入式系統(tǒng)及其開發(fā)應(yīng)用
- 玩轉(zhuǎn)智能機器人程小奔
- Hands-On Cloud Solutions with Azure
- 嵌入式Linux上的C語言編程實踐
- 空間傳感器網(wǎng)絡(luò)復(fù)雜區(qū)域智能監(jiān)測技術(shù)
- 80x86/Pentium微型計算機原理及應(yīng)用
- PostgreSQL Administration Essentials
- 大數(shù)據(jù)技術(shù)與應(yīng)用
- 運動控制系統(tǒng)
- 電腦上網(wǎng)輕松入門
- 格蠹匯編
- Mastering Ceph
- 步步驚“芯”
- 樂高創(chuàng)意機器人教程(中級 上冊 10~16歲) (青少年iCAN+創(chuàng)新創(chuàng)意實踐指導(dǎo)叢書)
- 伺服與運動控制系統(tǒng)設(shè)計