Skip to Main Content
Python Machine Learning By Example
book

Python Machine Learning By Example

by Yuxi (Hayden) Liu, Ivan Idris
May 2017
Beginner to intermediate content levelBeginner to intermediate
254 pages
6h 24m
English
Packt Publishing
Content preview from Python Machine Learning By Example

News topic classification with support vector machine

It is finally time to build our state-of-the-art, SVM-based news topic classifier with all we just learned.

Load and clean the news dataset with the whole 20 groups:

>>> categories = None>>> data_train = fetch_20newsgroups(subset='train',                            categories=categories, random_state=42)>>> data_test = fetch_20newsgroups(subset='test',                            categories=categories, random_state=42)>>> cleaned_train = clean_text(data_train.data)>>> label_train = data_train.target>>> cleaned_test = clean_text(data_test.data)>>> label_test = data_test.target>>> term_docs_train =                   tfidf_vectorizer.fit_transform(cleaned_train)>>> term_docs_test = tfidf_vectorizer.transform(cleaned_test)

Recall that the linear kernel is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Machine Learning by Example - Third Edition

Python Machine Learning by Example - Third Edition

Yuxi (Hayden) Liu
Python: Deeper Insights into Machine Learning

Python: Deeper Insights into Machine Learning

Sebastian Raschka, David Julian, John Hearty
Python: Real World Machine Learning

Python: Real World Machine Learning

Prateek Joshi, John Hearty, Bastiaan Sjardin, Luca Massaron, Alberto Boschetti

Publisher Resources

ISBN: 9781783553112Supplemental Content