Relationship Autopsy: A Story of Unrequited Love as Told By a Computer
Tags: python, opensource, analytics, nlp
Published: 2019-02-21 02:17:27

---
title: Relationship Autopsy: A Story of Unrequited Love as Told By a Computer
published: true
description: Once upon a time I met somebody. We texted all. damn. day. It was great. Apart from the impending flexibility limits in my thumbs, life was looking up.
cover_image: https://thepracticaldev.s3.amazonaws.com/i/cjtmccv6car6h4w56nww.png

tags: python, opensource, analytics, NLP
---

Originally published on [andcomputers.io](https://andcomputers.io/unrequited-love-as-told-by-a-computer/?utm_source=dev.to&utm_medium=crossplatformpost&utm_campaign=devtocrosspost)

![dont hit me when you in my city](https://thepracticaldev.s3.amazonaws.com/i/hpab4zjwnfd2m01u6ufn.png)

<h4>Happy Beginnings</h4><p>Once upon a time I met somebody. We texted all. damn. day. It was great. Apart from the impending flexibility limits in my thumbs, life was looking up.</p><p>I was like "cool", I'll probably be married soon, I should call my mom.</p>

<h4>The Beginning of the End</h4>

<p>Alas, I was wrong. Completely and utterly. Things started to slowly fizzle out and to this day i'm not really sure why, but I should've seen it coming. </p><p>Anyways, this story not really about this person, its about how my computer told me they just were not that into me. The data was all there, it just needed to be explored. </p>

<p>Below I'll share how I built a somewhat general purpose tool<sup>1</sup> to analyze iPhone text messages and what I learned.</p>

<h4>The Actual End</h4><p>It was raining super heavy outside... yet my phone was dry asf. Weird I thought. I usually get some texts coming in around this time. I think.</p>
<p>I'm racking my brain trying to remember if we had talked yesterday around this time.</p><p>I can't recall...What about this day last week?...Hmmm.</p>
<p> I'm coming up empty...I couldn't remember for the life of me if we had talked <em>more</em> or <em>less</em> in this last week than usual.</p> 


![bad text conversation](https://thepracticaldev.s3.amazonaws.com/i/b8sucvvp8l7wdojuo21i.png)


Was our nascent relationship fizzling out or heating up?</p><p>My intuition was telling me the former, but I wanted to see it for myself with some quantitative backing.</p><p>After a few minutes of thinking I knew precisely how I'd be spending the next few evenings of my life. </p><h4>The Mission</h4><p>First thing I did was open up the iMessages app on my computer and start copying and pasting the conversation into a text file. </p><p>A Fucking Terrible Idea™. A few minutes in and I realize I'll be doing this for at least 9 and a half hours before I get the whole conversation transferred into a readable file; there are thousands of texts. </p><p>There had to be a more efficient way to do this. I hoped (for both my curiosity and my rapidly deteriorating sense of normalcy) that I wasn't the only person in the world who had ever wanted to dump all of their text messages into <code>.txt</code> files.</p><p>After some google searching and stackoverflow investigations, things weren't looking too hot. I headed over to Github, a site where people share the code for their projects, and eventually stumble across this <a href="https://github.com/PeterKaminski09/baskup">gem</a>.</p>

{% github PeterKaminski09/baskup %}


<p>Somebody with equally questionable intentions had built a tool for Macs that finds the <code>chat.db</code> file. The file contains all of your conversations; provided that your iPhone is synced with your Mac. I was in luck, as a budding Apple Fanboy, my texts were definitely in that file. I run the program and after a few minutes of bash script magic - it finished!</p><p>Coooool, I had the text messages... At this point I'm already feeling like I just hacked into the Pentagon's highest security server. Side note: I have an astoundingly low bar for feeling like I'm doing very advanced things on my computer. Black screen + white text and I swear I'm <em>literally</em> inside of the matrix.</p><pre><code>&gt; me, inside the matrix.
&lt;code&gt;h4x0r&lt;/code&gt;</code></pre><p>As I'm was writing this, I realize that going through all the gory details about the implementation will probably take too long. I've written up a more in depth article as a <a href="https://andcomputers.io/conversational-analytics-a-technical-walkthrough/">separate blog post</a> that focuses on the technical aspects. If I do it here I'll get super carried away, so I'll just skip to the fun part.</p><h4>Quantifying an Almost-Sorta-Kinda-Mostly-Not-Relationship</h4><h6 id="cumulative-statistics">Cumulative statistics</h6><p>First things first, a quick look at some stats over the length of the text conversation, from the first text sent........to the last. <em>sigh</em></p>



![table with stats](https://thepracticaldev.s3.amazonaws.com/i/qfw24gmxh0438cj8e6vd.png)




<p>Overall, things don't look too bad in my opinion. We're pretty much even in most things if you ignore the <code>Link Rate</code> metric; I read and share tons of articles in general, so no surprises there. </p><p>The emojis look like we're laughing a lot and I'm eliciting many eye rolls as a result of being annoying. Again, no surprises there.</p><p><code>Number of Texts Sent</code> has an asterisk because the program has a special decision making process for determining what a "text" really is. If you're curious on the details check out the <a href="the other articlesSE!">technical write up</a>! </p><p>The real kicker comes when you look at data over time. </p><p>... <em>big sigh</em></p><h6 id="trends-over-time">Trends over time</h6><p>I decided to break the texts into three periods of about 15 days each. Viewing the graph below, which indicates how many texts were shared between two participants, its pretty clear what the phases were. Looking back, I realize that had I just paused for some computer-aided reflection, I could have seen, quantitatively, that our days were numbered.</p><p><strong>First Phase</strong>: frenetic high volume texting, life is good, no worries</p><p><strong>Second Phase</strong>: sustained and steady, healthy conversation</p><p><strong>Third Phase</strong>: "im good luv, enjoy"</p><p></p>



![texts over time](https://thepracticaldev.s3.amazonaws.com/i/go0cdhdsi7bmty8lhbxb.png)

<figcaption>Peep the slope to get a feel for conversation pace.</figcaption>



<p></p><p>I've plotted each metric contained  above over the three phases to see how these numbers trended over time. </p><p></p>



![phases of texting with metrics](https://thepracticaldev.s3.amazonaws.com/i/c1q4xkva21ilz7mcvcbb.png)




<p></p><p><strong>Last Phase Takeaways</strong>:</p><p> <code>wait time</code>: Super high delays between messages on both sides.</p><p> <code>link rate</code>: Lmao, 0.0 percent in the last phase. I for one, still had lots to share!</p><p><code>emoji rate</code>: We trended in complete opposite directions in our emoji usage.</p><p> <code>texts sent</code>: Clearly the number of texts sent in the last phase was way lower than any other period of time.</p><p><code>average length</code>: Along with there being less texts, each text was getting shorter over time. </p><h6 id="reflections">Reflections</h6><ul><li>I'm washed.</li><li>I probably didn't need a computer to tell me this.</li><li>I'm a chronic over-sharer.</li><li>May have enjoyed writing the code more than talking to humans... ?</li></ul><h6 id="bonus-section">Bonus Section</h6><p>There was some analysis on segmenting texts by day of the week and hour of the day that didn't provide a ton of insight but was still fun to do and provided cool visualization options. I'm including some extra plots just for fun, but I honestly don't have much to say about them. As you can imagine there's a lot of stuff not included in this article because of space and time, but there are tons of ways to slice and dice this data, here are a couple.</p>



![number of texts by hour](https://thepracticaldev.s3.amazonaws.com/i/j17h0il6i7pc255al5rb.png)
<figcaption>Check The Late Night Though (RNH) 😎</figcaption>

</br>
</br>



![wait time by day of week](https://thepracticaldev.s3.amazonaws.com/i/pj10gjfwiefcgxkkqxa6.png)
<figcaption>Keeping Sunday Holy 🙏🏿</figcaption><p></p><p></p><p>

<a href="https://github.com/weallwegot/conversation-analytics">Source Code Available Here</a></p>

{% github weallwegot/conversation-analytics %}


<p>As always thanks for reading, and please share your thoughts! Think I'm a weirdo? Coolest project you've ever seen? Ban me from using computers till my 40th birthday? Want to conduct your own post mortem relationship analysis? Suggestions for different metrics?</p>


<hr><p><sup>1</sup> Being the shitty developer that I am, the tool only works through a command line interface (CLI).  One day I'll build a UI and make the program run continuously. Just not today.. and probably not tomorrow.</p>