Book Image

Artificial Intelligence with Python

Book Image

Artificial Intelligence with Python

Overview of this book

Artificial Intelligence is becoming increasingly relevant in the modern world. By harnessing the power of algorithms, you can create apps which intelligently interact with the world around you, building intelligent recommender systems, automatic speech recognition systems and more. Starting with AI basics you'll move on to learn how to develop building blocks using data mining techniques. Discover how to make informed decisions about which algorithms to use, and how to apply them to real-world scenarios. This practical book covers a range of topics including predictive analytics and deep learning.
Table of Contents (23 chapters)
Artificial Intelligence with Python
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Building an Optical Character Recognition engine


Now that we have learned how to work with this data, let's build an optical character recognition system using artificial neural networks.

Create a new python file and import the following packages:

import numpy as np 
import neurolab as nl 

Define the input file:

# Define the input file 
input_file = 'letter.data' 

Define the number of datapoints that will be loaded:

# Define the number of datapoints to  
# be loaded from the input file 
num_datapoints = 50 

Define the string containing all the distinct characters:

# String containing all the distinct characters 
orig_labels = 'omandig' 

Extract the number of distinct classes:

# Compute the number of distinct characters 
num_orig_labels = len(orig_labels) 

Define the train and test split. We will use 90% for training and 10% for testing:

# Define the training and testing parameters 
num_train = int(0.9 * num_datapoints) 
num_test ...