Sub topic 7
Reading your log for patterns
This chapter assumes you have already kept a cue log for a week or two. Each entry records one occurrence of the habit you want to stop, with the time, place, mood, other people present, and the action just before it. It also assumes you know the habit loop: a cue, then a routine, then a reward. Here you will turn a pile of entries into a short list of candidate cues. The next chapter covers how to test whether those candidates are real.
What pattern analysis is for
A log is raw material. Read straight through, it tends to feel like noise, because every entry has five or six details and most of them differ from entry to entry. Analysis reduces that noise to a question you can answer: which detail shows up most often when the habit happens?
Three things to keep in mind:
- The goal is a ranked list of candidate cues, not a verdict. A frequent detail is a suspect, not a proven cause.
- You are looking at the cue side and the reward side together. The cue tells you when to intervene. The reward tells you what the habit is doing for you, which decides what a replacement routine must provide.
- A small log gives rough answers. With fewer than about 15 entries, treat every result as a hint.
Step 1: Clean the log before you count
Counting only works if the same thing is written the same way each time. Before you analyze, read the log once and fix the wording.
- Merge synonyms. "Desk", "my desk", and "work desk" should become one value. So should "bored" and "nothing to do", if you meant the same state.
- Keep categories separate. Do not let "stressed at my desk" sit in one field. Split it into a mood (stressed) and a place (desk).
- Mark missing values. If you did not note the mood on one entry, write "unknown". Do not guess. Guessed values add false patterns.
- Pick a fixed set of time bands, such as morning, afternoon, evening, and night. Exact clock times are too fine to count. Ten entries at ten different minutes show no pattern, but ten entries in the same afternoon band do.
Cleaning changes how you describe the data. It does not change what happened, so do not drop entries because they look odd.
Step 2: Count by category
For each category, tally how often each value appears. Then note the top value and its share of all entries. The share matters more than the raw count, because "6 times" means different things in a log of 8 entries and in a log of 40.
The script below automates this. It reads a list of entries, counts the values in each field, and prints the most frequent value with its count.
from collections import Counter
log = [
{"time": "afternoon", "place": "desk", "mood": "bored", "with": "alone", "before": "finished a task"},
{"time": "afternoon", "place": "desk", "mood": "stressed", "with": "alone", "before": "finished a task"},
{"time": "evening", "place": "sofa", "mood": "bored", "with": "alone", "before": "opened laptop"},
{"time": "afternoon", "place": "desk", "mood": "bored", "with": "coworker", "before": "finished a task"},
]
for field in ("time", "place", "mood", "with", "before"):
counts = Counter(entry[field] for entry in log)
value, n = counts.most_common(1)[0]
print(f"{field}: {value} ({n} of {len(log)})")Running it prints:
time: afternoon (3 of 4)
place: desk (3 of 4)
mood: bored (3 of 4)
with: alone (3 of 4)
before: finished a task (3 of 4)Every category has a top value that covers 3 of the 4 entries. This is the first lesson of the exercise: with only four entries, everything looks like a pattern. The output is a set of leads, not an answer.
What the output does and does not tell you
The script reports the single most common value in each field. That is useful for a first pass, but it has limits:
- It hides ties. If "bored" and "stressed" each appear twice,
most_common(1)shows only one of them. Print the full counts when the log is small. - It treats every field separately. It cannot tell you that "desk" and "finished a task" always occur together.
- It says nothing about how often you were in that situation without doing the habit. That gap is the subject of the next chapter.
To see the full counts for one field, change the loop body to print counts.most_common(). Do this whenever the top two values are close.
Step 3: Look for combinations
Single values are often weaker than combinations. In the sample log, "afternoon", "desk", and "finished a task" all appear together in three of four entries. That bundle is more specific than any one part of it, and specific cues are easier to act on.
To find bundles, read the entries that make up your top values and ask whether they are the same entries. If the top time, top place, and top preceding action all come from the same rows, you probably have one situation that repeats, not three separate cues.
You can count a pair directly:
from collections import Counter
log = [
{"time": "afternoon", "place": "desk", "before": "finished a task"},
{"time": "afternoon", "place": "desk", "before": "finished a task"},
{"time": "evening", "place": "sofa", "before": "opened laptop"},
{"time": "afternoon", "place": "desk", "before": "finished a task"},
]
pairs = Counter((e["place"], e["before"]) for e in log)
for (place, before), n in pairs.most_common():
print(f"{place} + {before}: {n} of {len(log)}")This prints:
desk + finished a task: 3 of 4
sofa + opened laptop: 1 of 4Pairs shrink quickly. A pair that covers half your entries is strong. A pair that covers one entry is just a description of one day.
Step 4: Rank the candidates
Turn your counts into a short list. Use these questions to rank each candidate.
- Coverage. What share of entries does it appear in? Higher is better.
- Specificity. Is it narrow enough to notice in the moment? "Afternoon" is broad. "Right after I close a task" is narrow.
- Position. Does it come before the habit starts? A mood that you only recorded after the fact may be a result of the habit, not a trigger for it.
- Consistency across entries. Does it show up in different weeks, or only on one bad day?
Then write down the top two or three candidates. More than three makes the next steps hard to carry out.
| Candidate | Coverage | Specific enough? | Comes before the habit? | Keep? |
|---|---|---|---|---|
| Finished a task | 3 of 4 | Yes | Yes | Yes |
| Afternoon | 3 of 4 | No, too broad | Yes | Yes, as context |
| Alone | 3 of 4 | Moderate | Yes | Check later |
| Bored | 3 of 4 | Moderate | Unclear | Check timing |
The "Bored" row shows a common problem. Boredom may be a cue, or it may be what you felt after the habit started to wear off. Check the order in your notes before you rely on it.
Step 5: Read the reward column
If you recorded what you got from the habit, or what you felt just afterward, analyze that field the same way. Count the rewards. Common ones include relief, stimulation, a break, company, and a sense of finishing something.
Then compare the two sides:
- If the same reward appears across all your cue bundles, the habit probably serves one need. A replacement routine should meet that need.
- If different cue bundles show different rewards, you may have two habits that look like one. Treat them separately.
- If you cannot name a reward, say so. Leave the field as "unknown" rather than inventing one.
For example, a habit that follows "finished a task" and rewards you with "a break" tells a different story than one that follows "stressed" and rewards you with "relief". The first may be about a pause. The second may be about escaping a feeling.
Edge cases and common errors
Too few entries
Small logs produce confident-looking numbers that mean little. If one value covers 3 of 4 entries, a different week might give 1 of 4. Keep logging until you have at least 15 to 20 entries before you rank candidates with any confidence.
A log that only records when the habit happened
Your log shows when the habit occurred. It does not show how often the same conditions occurred without the habit. If you sit at your desk every afternoon, "desk" will top your list whether or not it is a cue. This is the main source of false leads, and the next chapter addresses it.
Over-reading a single entry
One vivid entry, such as a day with an argument and a long drive, can feel important. Weight it by how often it repeats, not by how memorable it was.
Mixing several habits
If your log blends two behaviors, such as snacking and phone checking, the patterns blur. Keep one log per habit.
Changing the log while analyzing it
Do not add details from memory to make the pattern cleaner. Only fix wording. Added details tend to confirm what you already expect.
Time bands that hide the pattern
If you use four bands and most entries land in "afternoon", the band is too wide. Split it into early and late afternoon, or note the preceding action instead, which is often more precise than the clock.
A short workflow
The diagram shows the order of work in this chapter.
Putting the output to use
At the end of this process, you should have a short note like this:
- Top candidate: right after finishing a task, at my desk, in the afternoon. Covers 3 of 4 entries (to be rechecked when the log is larger).
- Possible secondary: bored, when alone. Timing unclear.
- Likely reward: a break from work.
- Open question: how often do I finish a task at my desk in the afternoon without doing the habit?
That last line is the bridge to the next chapter. A candidate becomes a likely cue only after you check it against the times the habit did not happen.
Summary
- Clean the wording, merge synonyms, and mark unknowns before counting.
- Count each category, and report the share of entries, not only the raw count.
- Check combinations, because a bundle of values is more specific than one value.
- Rank candidates by coverage, specificity, position before the habit, and consistency.
- Read the reward column the same way, and note whether it matches across cue bundles.
- Keep your list to two or three candidates, and record the open question for the next chapter.
Exercise
A log of 20 entries for evening snacking shows these top values: place = kitchen (16 of 20), mood = tired (9 of 20), preceding action = washed the dinner dishes (11 of 20). Rank the three as candidate cues and give one reason each for the order. Also name one fact you would still need before calling the top one a cue.
Show answer
A reasonable ranking is: (1) kitchen, (2) washed the dinner dishes, (3) tired. Kitchen has the highest coverage at 80 percent, but it is also broad, and the dishes are washed in the kitchen, so the two may be the same situation. Washed the dinner dishes covers 55 percent, is narrow enough to notice in the moment, and comes before the snacking, so it is the most useful one to act on and may deserve first place if you value specificity over coverage. Tired covers 45 percent and may be a result of the evening as much as a cause, so check when you recorded it. Either order is defensible if you state the reason. The missing fact is how often you were in the kitchen, or finished the dishes, without snacking. Without that comparison, a place you are in every evening will top the list whether or not it is a cue.
Exercise
Using the first Python script in this chapter, you change the log to 6 entries in which "bored" appears 3 times and "stressed" appears 3 times in the mood field. What does the script print for mood, and what should you do about it?
Show answer
It prints only one of the two values, for example "mood: bored (3 of 6)", because mostcommon(1) returns a single item and ties are not shown. Stressed would be hidden. To see both, print counts.mostcommon() for that field. Then treat both moods as candidates, and check whether they point to different rewards, which could mean two separate habits.