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 = num_datapoints - num_train
Define...