Monday, April 2, 2018

Heartbeat Recognition In Python


Biometric passwords are becoming more mainstream in society.  Iris scans, facial recognition, and fingerprints are slowly replacing passwords, as they are unique to each person and can't be forgotten.

But how does this tech work?

When you add your fingerprint to an iPhone for example, you have to press your thumb to the home button about 20 times.  These prints are recorded and called a Training Set, which trains the iPhone to recognize your thumb in different positions.  Each print in the Training set is stored as a list of Features, or predictors that show what makes your thumb different from everyone else (source).

Fingerprints have been used for identification for over 120 years, and have been verified that no two are alike.  However, are other biometrics, such as heartbeats, able to identify a person out of a group?  Surprisingly, the answer is yes.  Heartbeats are collected using Electrocardiogram (EKG) machines.  (If you have watched any hospital show, these are those beeping machines next to patients).

For a semester project in my Biology class, I decided to make an EKG recognition program myself.  I recruited ten of my classmates and read their heartbeats with an EKG recorder three times.  For each person, two recordings were put into the Training set, and the third was used for calculating the accuracy of the algorithm.  After all the samples were taken, I wrote a quick Python script to extract features from the EKG readings.  The script looked at the local maximum and minimums of each heartbeat, as well as the distances between them.  Then, I used a Bagging Classification algorithm to see if I could guess the identity of each subject out of a group, using only their heartbeat.

Surprisingly, the prediction algorithm could correctly identify 8 out of the 10 subjects on the first guess.  While not close to perfect, a random guess would only correctly identify 1 of the 10 subjects.  The program on average took 2 guesses on any subject to correctly guess the person's identity.

A main source of error in the experiment was the quality of the lab's EKG machines.  While hospital-grade EKG's have accurate recordings like the picture above, the school's EKG recordings looked more like sine waves.  In addition, more error could exist in the data collection because I am an amateur at recording heart beats.

After developing the heartbeat recognition algorithm, I confirmed that a person's heartbeat is unique enough to correctly identify them out of a group of people.






No comments:

Post a Comment