www.allitebooks.com
Learning%20Data%20Mining%20with%20Python Learning%20Data%20Mining%20with%20Python
Beating CAPTCHAs with Neural Networks Interpreting information contained in images has long been a difficult problem in data mining, but it is one that is really starting to be addressed. The latest research is providing algorithms to detect and understand images to the point where automated commercial surveillance systems are now being used—in real-world scenarios—by major vendors. These systems are capable of understanding and recognizing objects and people in video footage. It is difficult to extract information from images. There is lots of raw data in an image, and the standard method for encoding images—pixels—isn't that informative by itself. Images—particularly photos—can be blurry, too close to the targets, too dark, too light, scaled, cropped, skewed, or any other of a variety of problems that cause havoc for a computer system trying to extract useful information. In this chapter, we look at extracting text from images by using neural networks for predicting each letter. The problem we are trying to solve is to automatically understand CAPTCHA messages. CAPTCHAs are images designed to be easy for humans to solve and hard for a computer to solve, as per the acronym: Completely Automated Public Turing test to tell Computers and Humans Apart. Many websites use them for registration and commenting systems to stop automated programs flooding their site with fake accounts and spam comments. The topics covered in this chapter include: • Neural networks • Creating our own dataset of CAPTCHAs and letters • The scikit-image library for working with image data • The PyBrain library for neural networks [ 161 ]
Beating CAPTCHAs with Neural Networks • Extracting basic features from images • Using neural networks for larger-scale classification tasks • Improving performance using postprocessing Artificial neural networks Neural networks are a class of algorithm that was originally designed based on the way that human brains work. However, modern advances are generally based on mathematics rather than biological insights. A neural network is a collection of neurons that are connected together. Each neuron is a simple function of its inputs, which generates an output: The functions that define a neuron's processing can be any standard function, such as a linear combination of the inputs, and are called the activation function. For the commonly used learning algorithms to work, we need the activation function to be derivable and smooth. A frequently used activation function is the logistic function, which is defined by the following equation (k is often simply 1, x is the inputs into the neuron, and L is normally 1, that is, the maximum value of the function): The value of this graph, from -6 to +6, is shown as follows: [ 162 ]
- Page 133 and 134: Social Media Insight Using Naive Ba
- Page 135 and 136: Social Media Insight Using Naive Ba
- Page 137 and 138: Social Media Insight Using Naive Ba
- Page 139 and 140: Social Media Insight Using Naive Ba
- Page 141 and 142: Social Media Insight Using Naive Ba
- Page 143 and 144: Social Media Insight Using Naive Ba
- Page 145 and 146: Social Media Insight Using Naive Ba
- Page 147 and 148: Social Media Insight Using Naive Ba
- Page 149 and 150: Social Media Insight Using Naive Ba
- Page 151 and 152: Social Media Insight Using Naive Ba
- Page 153 and 154: Social Media Insight Using Naive Ba
- Page 155 and 156: Social Media Insight Using Naive Ba
- Page 158 and 159: Discovering Accounts to Follow Usin
- Page 160 and 161: Chapter 7 Next, we will need a list
- Page 162 and 163: Chapter 7 Make sure the filename is
- Page 164 and 165: Chapter 7 cursor = results['next_cu
- Page 166 and 167: Chapter 7 Next, we are going to rem
- Page 168 and 169: Chapter 7 Creating a graph Now, we
- Page 170 and 171: Chapter 7 As you can see, it is ver
- Page 172 and 173: Chapter 7 Next, we will only add th
- Page 174 and 175: Chapter 7 The difference in this gr
- Page 176 and 177: Chapter 7 We can graph the entire s
- Page 178 and 179: Chapter 7 Optimizing criteria Our a
- Page 180 and 181: Chapter 7 Next, we need to get the
- Page 182 and 183: • method='nelder-mead': This is u
- Page 186 and 187: Chapter 8 The red lines indicate th
- Page 188 and 189: Chapter 8 The combination of an app
- Page 190 and 191: Chapter 8 Next we set the font of t
- Page 192 and 193: Chapter 8 We can then extract the s
- Page 194 and 195: Chapter 8 Our targets are integer v
- Page 196 and 197: Chapter 8 Then we iterate over our
- Page 198 and 199: Chapter 8 From these predictions, w
- Page 200 and 201: Chapter 8 This code correctly predi
- Page 202 and 203: The result is shown in the next gra
- Page 204 and 205: Chapter 8 However, it isn't very go
- Page 206: Chapter 8 Summary In this chapter,
- Page 209 and 210: Authorship Attribution Attributing
- Page 211 and 212: Authorship Attribution If we cannot
- Page 213 and 214: Authorship Attribution After taking
- Page 215 and 216: Authorship Attribution This dataset
- Page 217 and 218: Authorship Attribution "instead", "
- Page 219 and 220: Authorship Attribution Support vect
- Page 221 and 222: Authorship Attribution Kernels When
- Page 223 and 224: Authorship Attribution We can reuse
- Page 225 and 226: Authorship Attribution With our dat
- Page 227 and 228: Authorship Attribution We then reco
- Page 229 and 230: Authorship Attribution If it doesn'
- Page 231 and 232: Authorship Attribution Finally, we
Beating CAPTCHAs with<br />
Neural Networks<br />
Interpreting information contained in images has long been a difficult problem in<br />
data mining, but it is one that is really starting to be addressed. The latest research is<br />
providing algorithms to detect and understand images to the point where automated<br />
<strong>com</strong>mercial surveillance systems are now being used—in real-world scenarios—by<br />
major vendors. These systems are capable of understanding and recognizing objects<br />
and people in video footage.<br />
It is difficult to extract information from images. There is lots of raw data in an<br />
image, and the standard method for encoding images—pixels—isn't that informative<br />
by itself. Images—particularly photos—can be blurry, too close to the targets, too<br />
dark, too light, scaled, cropped, skewed, or any other of a variety of problems that<br />
cause havoc for a <strong>com</strong>puter system trying to extract useful information.<br />
In this chapter, we look at extracting text from images by using neural networks<br />
for predicting each letter. The problem we are trying to solve is to automatically<br />
understand CAPTCHA messages. CAPTCHAs are images designed to be easy for<br />
humans to solve and hard for a <strong>com</strong>puter to solve, as per the acronym: Completely<br />
Automated Public Turing test to tell Computers and Humans Apart. Many websites<br />
use them for registration and <strong>com</strong>menting systems to stop automated programs<br />
flooding their site with fake accounts and spam <strong>com</strong>ments.<br />
The topics covered in this chapter include:<br />
• Neural networks<br />
• Creating our own dataset of CAPTCHAs and letters<br />
• The scikit-image library for working with image data<br />
• The PyBrain library for neural networks<br />
[ 161 ]