BUY THIS BOOK
Add to Cart

Print Book $39.99


Add to Cart

PDF $27.99

Safari Books Online

What is this?

Add to UK Cart

Print Book £24.99

What is this?

Looking to Reprint or License this content?

Programming Collective Intelligence Building Smart Web 2.0 Applications

By Toby Segaran
First Edition  August 2007 
Pages: 360
ISBN 10: 0-596-52932-5 | ISBN 13: 9780596529321
starstarstarstarstar (Average of 8 Customer Reviews)

Buy 2 Get 1 Free Free ShippingGuarantee

Book description

This fascinating book demonstrates how you can build web applications to mine the enormous amount of data created by people on the Internet. With the sophisticated algorithms in this book, you can write smart programs to access interesting datasets from other web sites, collect data from users of your own applications, and analyze and understand the data once you've found it.
Full Description

Want to tap the power behind search rankings, product recommendations, social bookmarking, and online matchmaking? This fascinating book demonstrates how you can build Web 2.0 applications to mine the enormous amount of data created by people on the Internet. With the sophisticated algorithms in this book, you can write smart programs to access interesting datasets from other web sites, collect data from users of your own applications, and analyze and understand the data once you've found it.

Programming Collective Intelligence takes you into the world of machine learning and statistics, and explains how to draw conclusions about user experience, marketing, personal tastes, and human behavior in general -- all from information that you and others collect every day. Each algorithm is described clearly and concisely with code that can immediately be used on your web site, blog, Wiki, or specialized application. This book explains:
  • Collaborative filtering techniques that enable online retailers to recommend products or media
  • Methods of clustering to detect groups of similar items in a large dataset
  • Search engine features -- crawlers, indexers, query engines, and the PageRank algorithm
  • Optimization algorithms that search millions of possible solutions to a problem and choose the best one
  • Bayesian filtering, used in spam filters for classifying documents based on word types and other features
  • Using decision trees not only to make predictions, but to model the way decisions are made
  • Predicting numerical values rather than classifications to build price models
  • Support vector machines to match people in online dating sites
  • Non-negative matrix factorization to find the independent features in a dataset
  • Evolving intelligence for problem solving -- how a computer develops its skill by improving its own code the more it plays a game
Each chapter includes exercises for extending the algorithms to make them more powerful. Go beyond simple database-backed applications and put the wealth of Internet data to work for you.

"Bravo! I cannot think of a better way for a developer to first learn these algorithms and methods, nor can I think of a better way for me (an old AI dog) to reinvigorate my knowledge of the details."
-- Dan Russell, Google

"Toby's book does a great job of breaking down the complex subject matter of machine-learning algorithms into practical, easy-to-understand examples that can be directly applied to analysis of social interaction across the Web today. If I had this book two years ago, it would have saved precious time going down some fruitless paths."
-- Tim Wolters, CTO, Collective Intellect
Post-purchase benefits:

Register your book | Submit Errata | Examples


Browse within this book

Cover | Table of Contents | Index | Sample Chapter | Colophon

Book details

First Edition: August 2007
ISBN: 0-596-52932-5
Pages: 360
Average Customer Reviews: starstarstarstarstar (Based on 8 Reviews)


Featured customer reviews

Write a Review


Very informative, engaging read. Code a bit terse,  April 16 2008
Rating: StarStarStarStarStar
Submitted by Jeff   [Respond | View]

Everything that everyone else has said about how well written this book is, how applicable the examples are, etc, is spot on. It's a very engaging read.

I have a single request. Could someone make a downloadable version of the code available with more descriptive variable names. (Terse is fine for the book itself). I'm finding I'm having to rename variables as I go so that I can more easily grasp the math.

An example of one that I've renamed:

def sim_pearson(prefs,p1,p2):
# Get the list of mutually rated items
mutuallyRatedItems={}
for item in prefs[p1]:
if item in prefs[p2]: mutuallyRatedItems[item]=1

# if they are no ratings in common, return 0
if len(mutuallyRatedItems)==0: return 0

# Sum calculations
numMutuallyRatedItems=len(mutuallyRatedItems)

# Sums of all the preferences
sum_Person1_MutuallRatings=sum([prefs[p1][item] for item in mutuallyRatedItems])
sum_Person2_MutuallRatings=sum([prefs[p2][item] for item in mutuallyRatedItems])

# Sums of the squares
sumOfSquaresOfPerson1MutualRatings=sum([pow(prefs[p1][item],2) for item in mutuallyRatedItems])
sumOfSquaresOfPerson2MutualRatings=sum([pow(prefs[p2][item],2) for item in mutuallyRatedItems])

# Sum of the products
sum_ProductOf_Ratings_OfBothUsers_MutualItems=sum([prefs[p1][item]*prefs[p2][item] for item in mutuallyRatedItems])

# Calculate r (Pearson score)
numerator=sum_ProductOf_Ratings_OfBothUsers_MutualItems-(sum_Person1_MutuallRatings*sum_Person2_MutuallRatings/numMutuallyRatedItems)
denominator=sqrt((sumOfSquaresOfPerson1MutualRatings-pow(sum_Person1_MutuallRatings,2)/numMutuallyRatedItems)*(sumOfSquaresOfPerson2MutualRatings-pow(sum_Person2_MutuallRatings,2)/numMutuallyRatedItems))
if denominator==0: return 0

pearsonCorrelation=numerator/denominator

return pearsonCorrelation

Great book. I'm really enjoying it.


Grant V,  December 13 2007
Rating: StarStarStarStarStar
Submitted by Anonymous Reader   [Respond | View]

This book is a must read for web developers wanting to go beyond CRUD. The author presents fairly complex topics in a brief yet easy to understand manner. I really appreciate how the most appropriate algorithms were chosen and then how practical examples of their use are given. I am neither a Python programmer nor a math genius and managed to get tons of value from this material.


At Last! An accessible book on machine learning,  November 23 2007
Rating: StarStarStarStarStar
Submitted by Tim Harvey   [Respond | View]

I have slugged my way through my share of major texts and academic papers on machine learning, data mining, NLP, and so on, and this book is a breath of fresh air. It is the first book I've seen that makes the topic accessible and has the reader immediately work with a great cross section of useful methods and applications.

The writing is clear, and rests on a good selection of problems and applications, instead of highly technical descriptions of algorithms. It appears squarely aimed at people who want to learn by working with real problems and data, and build up a good, workable toolkit, in the process.

Within my own profession, technical writing, structured documentation and technologies like DITA and document reuse represent the cutting edge in controlled documentation but the profession has no answer to democratic writing and publishing, represented by the web and wikis, that are overwhelming controlled writing and publishing. This book finally opens that door and provides the profession with the means to work with democratic material. I strongly urge members of my profession to study this book, and learn a different approach to how content can be detected, rated, and organized.



Tim Harvey

Text Wrestler, Google


Read all reviews


Amust read for webstie development,  November 08 2007
Rating: StarStarStarStarStar
Submitted by Doug Wake   [Respond | View]


What an awesome book. Collective Intelligence shows you how to utilize mathematical search algorithms in a way for analyzing websites. In school I learned calcIII and calcV which was series and matrices respectively to analyze numbers. Well in this book you begin by understanding how to search for a character or string of data with a very well laid out plan. You even get to use real time data when developing your project in Python.

Then the improvement, when using some algorithms, Euclidian distance, Pearson coefficient, Entropy, Conditional Probability, you begin to utilize numbers by giving your websites a weight for how you search. Toby Segaran is excellent in explanation of building a smart web application to keep track where you go. It also teaches you to find out who has visited your site as well as the probability that your site will be chosen next.

Also with utilizing these search algorithms is good way to show the history of data to gain marketing for advertisements. Utilizing AI in the back ground is always great find but can be difficult to teach, but this book was laid out very well in getting to the point for a programmer to learn high rate math algorithms.


What a nice read,
Doug Wake



Great book for smart web apps,  November 06 2007
Rating: StarStarStarStarStar
Submitted by W. Blanchard   [Respond | View]

I just read Collective Intelligence. I found it very useful in understanding the different methods used to collect data. This evolved from using algorithms suited for a certain problem to creating your own algorithms with machine-learning techniques. The many different algorithms and python script examples were helpful.


Noah Gift photo A great book for any web developer or AI geek.,  October 29 2007
Rating: StarStarStarStarStar
Submitted by Noah Gift   [Respond | View]

I was quite excited to get a copy of Collective Intelligence to review for the PyAtl Bookclub, as I am extremely interested in Artificial Intelligence. I was also extremely pleased to learn that Collective Intelligence used Python, exclusively, throughout the book to explain the author's ideas. There is a certain like minding thinking that Python Programmers share and it certainly comes through in this book by Toby Segaran.

With these high expectations on the table, it would have been easy for me to be disappointed, but the book met the expectations that I had, and in certain situations, exceeded them. One of the great aspects of Python, is that is so pragmatic. In a trivial amount of code, this book explained how to apply unsupervised learning techniques to RSS feeds. I had been meaning for quite some time to write some code that parsed RSS feeds and determined relevant information for me automatically. In Chapter 2, the book jumps right into using the "feedparser" module, to do just that! There are also great examples of using, "urllib2", and SQLite, in that same chapter.

Throughout, the rest of the book, Toby explores various other AI techniques, and explains clearly, how to implement them in Python. One nice touch at the end of the book, was to include a reference to modules used in the book, and to include small usage examples. I was quite pleased by Collective Intelligence, and I would recommend the book to any intermediate to advanced programmer who wants to learn more about AI, and also web specific applications of AI theory.

PyAtl Bookclub Review (http://pyatl.blogspot.com/2007/10/review-of-collective-intelligence.html)


Best book from this year...,  September 22 2007
Rating: StarStarStarStarStar
Submitted by Alexandre Dulaunoy   [Respond | View]

This book is surely the book of the year published by O'Reilly. The organization of the book is well done, the Python code example are concise and clear, the mathematical explanation are clever and simple...

Sometimes when reading a book, the quality between chapters changes but here all chapter meet a very high level of quality. A must to have on your bookshelf if you deal with a lot of user-contributed data from web services.




The most accessible book on machine learning I've found,  September 11 2007
Rating: StarStarStarStarStar
Submitted by Thomas Lockney   [Respond | View]

I first learned of this book just a few weeks ago, shortly before it was available. I immediately read the sample chapter on the publisher's website and was certain I had to get a hold of a copy.

I was not in the least bit disappointed with what I found. It has been quite a while since I've looked at any Python code (I'm more of a Ruby fan, personally), but the code is easy to follow and it's a simple matter to extract the basic concepts into any language.

I have spent quite a few years now watching the field of machine intelligence from the sidelines, occasionally reading the odd technical write up or wikipedia article, trying to wrap my brain around the basic ideas. The thing is, it's not clear to me that in some regards, it's not that complex. It's just that most of the existing books and articles are written for those immersed in the field. This book is not like that. It explains things in clear language that is easy to follow, using simplified examples and making excellent use of graphics to "show" you how it works.

If you really want to dig in deep, Segaran provides exercises at the end of each chapter and gives you an appendix full of mathematical formulas (the "pure" representation of the algorithms).

Finally, I should mention that the last chapter does what so many other technical books should but don't: it clearly summarizes everything he has shown you. He does this in a straightforward way so that you won't have to go searching through the book, rereading everything again, to put these techniques into practice.

(note: I originally published this review on Amazon, but this book deserves that I print it here, too.)


Media reviews
"Toby's book does a great job of breaking down the complex subject matter of machine-learning algorithms into practical, easy-to-understand examples that can be directly applied to analysis of social interaction across the Web today. If I had this book two years ago, it would have saved precious time going down some fruitless paths."
-- Tim Wolters, CTO, Collective Intellect


"If you are into developing intelligent software, or simply learning more about intelligent methods, this is a great book for you. The book is very well written with easy to follow Python code, clear explanations of the code, and then something often overlooked: showing the results. The interactive nature of Python allows you to work thru each code example. This makes for an excellent learning paradigm...This is the kind of book, I wish I had a month off to work thru all the examples, even as a good review."
-- John Taber, the truth is out there


"Bravo! I cannot think of a better way for a developer to first learn these algorithms and methods, nor can I think of a better way for me (an old AI dog) to reinvigorate my knowledge of the details."
-- Dan Russell, Google


"Programming Collective Intelligence is my “must have” book for 2007. I’ve been looking for a book that was able to explain machine learning, data mining and the related mathematics. I think I’ve found it! "
-- Aneesha, Random Syntax


"I first learned of this book just a few weeks ago, shortly before it was available. I immediately read the sample chapter on the publisher's website and was certain I had to get ahold of a copy...I was not in the least bit disappointed with what I found. It has been quite a while since I've looked at any Python code (I'm more of a Ruby fan, personally), but the code is easy to follow and it's a simple matter to extract the basic concepts into any language...Finally, I should mention that the last chapter does what so many other technical books should but don't: it clearly summarizes everything he has shown you. He does this in a straightforward way so that you won't have to go searching through the book, rereading everything again, to put these techniques into practice."
-- Thomas Lockney, ama


"Once in a while a book comes in that breaks the mold. Programming Collective Intelligence: Building Smart Web 2.0 Applications, by Toby Segaran is one of them. Basically, Programming Collective Intelligence is a book about analyzing Web data using statistical and AI methods in Python. It's more interesting than that sounds, however, at least partly because it's very practical and pragmatic."
-- Martin Heller, Strategic Developer


"It's an excellent book for anyone who wonders how to use data from other websites or how to use user behavior to learn how to service those users better. Toby Segaran, the author, uses a clear and expository style that allows you to learn how collective intelligence techniques work, in addition to seeing implementations of the techniques (in Python, but porting from Python isn't difficult, especially with how clear his explanations are.)...All told, it's a fascinating book. Web 2.0 isn't just about interactivity – it’s about intelligence, too. Interactivity is easy to achieve, with so many web frameworks that focus on interaction. Intelligence is a little harder – and this book goes a long way to making it easy."
-- Joseph Ottinger, TheServerSide.COM


"Statistical programmers will probably find years of entertainment here. :) "Normal" programmers will expand their horizons, too."
-- Thomas Duff, Duffbert's Random Musings


"Segaran's examples are all interesting, and both his explanations and his code are exceptionally clear. Some readers will find there's more math in the book than they'd like, but given the subject matter, that can't be helped. With a few more exercises at the end of each chapter, it'd be a great textbook; as it is, it's an excellent introduction to a topic that grows more important every day."
-- Gregory V. Wilson, Dr. Dobb's Portal


"This is one of the best books I've read in the last few years. It has a very natural and easy to follow format, with simple but powerful pieces of code written in Python...I highly recommend this book to learn about different techniques and to give you insight of what you can do with information in general. "
-- Gustavo Cavalcanti, Amazon.com


"If you're working with existing data this may spark off an inspiration that will let you add some new features or up your accuracy. Or if you're presented with a problem this book may give you techniques that will help you solve it without having to work everything out from first principles. It's well written manual that'll handily expand your repertoire."
-- Simon Winstow, London Perl Mongers


"Any library strong in programmer's guides needs Programming Collective Intelligence: it backs in details on machine statistics and uses these insights as models for creating more effective online systems."
-- James Cox, The California Bookwatch


"Programming Collective Intelligence is far more than a guide to building recommendation systems...If you ever find yourself browsing or referencing your algorithms text from college or even seriously studying algorithms for fun or profit, then I would highly recommend this book...probably the best one for relative beginners that is going to be available for a long time.If you ever find yourself browsing or referencing your algorithms text from college or even seriously studying algorithms for fun or profit, then I would highly recommend this book depending on your background in mathematics and computer science. That is, if you have a strong background in the academic study of related research, then you might look elsewhere, but this book, certainly suitable as an undergraduate text, is probably the best one for relative beginners that is going to be available for a long time."
-- Joe Kauzlarich, Slashdot.org

Hide extended reviews


See larger cover


"If I had this book two years ago, it would have saved precious time going down some fruitless paths."
--Tim Wolters, CTO, Collective Intellect