Book Image

Learning Data Mining with Python - Second Edition

By : Robert Layton
Book Image

Learning Data Mining with Python - Second Edition

By: Robert Layton

Overview of this book

This book teaches you to design and develop data mining applications using a variety of datasets, starting with basic classification and affinity analysis. This book covers a large number of libraries available in Python, including the Jupyter Notebook, pandas, scikit-learn, and NLTK. You will gain hands on experience with complex data types including text, images, and graphs. You will also discover object detection using Deep Neural Networks, which is one of the big, difficult areas of machine learning right now. With restructured examples and code samples updated for the latest edition of Python, each chapter of this book introduces you to new algorithms and techniques. By the end of the book, you will have great insights into using Python for data mining and understanding of the algorithms as well as implementations.
Table of Contents (20 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Putting it all together


We can use the existing parameter space and the existing classifier from our previous experiments—all we need to do is refit it on our new data. By default, training in scikit-learn is done from scratch—subsequent calls to fit() will discard any previous information.

Note

There is a class of algorithms called online learning that update the training with new samples and don't restart their training each time. 

As before, we can compute our scores by using cross_val_score and print the results. The code is as follows:

scores = cross_val_score(pipeline, documents, classes, scoring='f1') 

print("Score: {:.3f}".format(np.mean(scores)))

The result is 0.683, which is a reasonable result for such a messy dataset. Adding more data (such as increasing max_docs_author in the dataset loading) can improve these results, as will improving the quality of the data with extra cleaning.