Skip to content

Instantly share code, notes, and snippets.

@FrankRuns
Created June 20, 2021 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrankRuns/9a7ce83e1a79f99cec1e16fb6ba97683 to your computer and use it in GitHub Desktop.
Save FrankRuns/9a7ce83e1a79f99cec1e16fb6ba97683 to your computer and use it in GitHub Desktop.
Turning vision docs into data
# packages
library(syuzhet)
library(dplyr)
library(ggplot2)
# subset of text (to start)
limiting_beliefs <- "I never had a plan for my career and now it’s too late.
I wanted to be X, but didn’t start early enough in life and now it’s too late.
I go to work to support my family, not to be fulfilled.
I can’t make enough money doing a job I want to do.
I’m not smart enough to do the jobs I want to do.
I’m afraid to give up monetary compensation for self realization.
I can have a fulfilling career if I just stick to the path I’m on now.
I hate commuting.
I hate recurring, worthless meetings.
Everyone commutes, everyone has marginally valuable meetings. It’s just part of life.
I can’t work with people I want to work with.
I suck at managing people, which makes me a bad leader.
"
# calculate overal sentiment
syuzhet_vector <- get_sentiment(get_sentences(limiting_beliefs), method="syuzhet")
mean(syuzhet_vector)
# function to continuously analyze sentiment and emotions
sentiment_matrix <- function(text) {
text_sentences <- get_sentences(text)
print(text_sentences)
text_vector <- get_sentiment(text_sentences, method="syuzhet")
print("Mean of text vector: ", mean(text_vector))
text_sentiment <- get_nrc_sentiment(text_sentences)
print(text_sentiment)
barplot(
sort(colSums(prop.table(text_sentiment[, 1:8]))),
horiz = TRUE,
cex.names = 0.7,
las = 1,
main = "Emotions in Vision Doc", xlab="Percentage"
)
return(colSums(text_sentiment))
}
# analyze sentiment and emotions for limiting beleifs
sentiment_matrix(limiting_beliefs)
# entire text
career_text <- "I never had a plan for my career and now it’s too late.
I wanted to be X, but didn’t start early enough in life and now it’s too late.
I go to work to support my family, not to be fulfilled.
I can’t make enough money doing a job I want to do.
I’m not smart enough to do the jobs I want to do.
I’m afraid to give up monetary compensation for self realization.
I can have a fulfilling career if I just stick to the path I’m on now.
I hate commuting.
I hate recurring, worthless meetings.
Everyone commutes, everyone has marginally valuable meetings. It’s just part of life.
I can’t work with people I want to work with.
I suck at managing people, which makes me a bad leader.
I am qualified to do anything I want to do.
I have a network to support me in succeeding in anything I want to do.
My wife and I are incredibly fiscally responsible.
I love data and data-related work.
I have an unusual ability to focus on stuff for prolonged periods of time.
My family wants me to be fulfilled in the work I do.
I am a leader, in ways different from other people.
I have control over my day - I determine when, where, and why I am at places.
Intellectual challenges inspire me.
I find meaning in my work.
My work improves people’s lives.
I build beautiful things.
I’m constantly connecting dots. Putting together different ideas in novel ways. I use data and analytics (including machine learning techniques like reinforcement learning) to do this. I’m constantly assessing risks and trade-offs. My domain is broader than a single field. I lead a team - or even a company - that helps me do this. We work in several fields including healthcare, finance, education, entertainment, and technology (any place we consider might lead to changing the world) - we attempt to borrow ideas from different domains and apply to elsewhere. We are on a mission - when we miss deadlines we let ourselves down, not our managers. We are beholden to ourselves before our investors. We love applying network science where applicable (and not applicable :).
How I work is just as important as what I work on. Who I work with is, also, just as important as what I work on. I travel sometimes - but never for frivolous meetings. I have a central work space for my team/company, but never feel guilty about working at home. We (me and/or my team/company) have been trained at best practice for communicating when we are not in the same physical space. We use the best technology to do that. We trust each other.
I am constantly building positive net wealth - through a well-diversified stream of incomes and portfolios. I’ve gotten to a point where I’m more concerned about how much money I’ve invested in people rather than how much money I’ve brought in the door.
I get asked to speak at data science, economics, and X strategy conferences. I write a lot - for my team/company, for the public, for friends, for myself. Writing helps me think through the problems we are trying to solve. Sometimes I publish before I have what I would consider a final draft - I’m OK with this because it helps me get feedback faster and think through the problem faster. I love producing beautiful things - tools, newsletters, blogs, presentations, videos, groups of the right people. Angles inspire me, curves less so.
Being marginal (or feeling like I’m marginal).
Commuting regularly to the same place to spin my wheels doing the same things.
Mundane meetings.
Boredom.
Limitations on how I manage my time and life.
Regretting not spanning time with my kids & wife - and people I value tremendously.
Feeling like I didn’t find the balance I wanted to.
Smiling every day - being grateful for being alive.
Finding a balance that brings me joy over 99% of each day.
Loving those around me.
Creating positive change in my world - and the world of those around me.
Feeling recognized.
Concentrated anxiety, pressure and relief upon success (races, presentations are good examples of this… being on-time to pointless corporate meetings is the opposite) which I know leads to growth.
Loot, having a lot of it which creates the ability to help people financially.
Reconnect with Matt Stofen at Target that works in Enterprise Strategy.
Let Brad Zehlke and Brad Thomspon know you are intent on moving over to Data Science at Target.
Step it up with writing - it doesn’t have to be perfect:
Publish Forecast Framework blog post (Monday).
Create pipeline of blog posts that you want to post (including heavy focus on network sciences).
Restart the Supply Chain Performance Newsletter at Target.
Read Super Thinking in October.
Inquire with HR at Target about training for remote working.
Start working at home 1 day per week - use that commute time to write and/or read. Experiment with different techniques for productively working remotely.
Could also consider working at a coffee shop - change of scenery.
Send AM specs for BestRoute v1.
At Target, determine the non-data science work your team does and figure out how to do less of that.
Start working with Udacity again - they have lots of part-time, remote ways of contributing to students.
"
# how many mostly positive and mostly negative sentences
temp <- get_nrc_sentiment(get_sentences(career_text))
temp$gravity <- temp$positive - temp$negative
temp$g_bucket <- ifelse(temp$gravity<0, "neg", ifelse(temp$gravity==0, "neu", "pos"))
# analyze sentiment and emotions for entire doc
sentiment_matrix(career_text)
# analyze emotional entropy for entire doc
career_sents <- get_sentences(career_text)
test <- lapply(career_sents, mixed_messages)
entropes <- do.call(rbind, test)
out <- data.frame(entropes, career_sents, stringsAsFactors = FALSE)
simple_plot(out$entropy,title = "Emotional Entropy Through Vision Doc",legend_pos = "top")
metric_sorted <- arrange(out, desc(metric_entropy)) %>%
select(metric_entropy, career_sents)
metric_sorted[1:5,]
# visualize sentiment against emotional entropy
s_v_sentiment <- get_sentiment(career_sents)
out$round_entropy <- round(out$metric_entropy, 1)
out$sentiment <- s_v_sentiment
ggplot(out, aes(x=sentiment, y=metric_entropy)) +
geom_point() +
geom_hline(yintercept=0.071, color="blue") +
geom_vline(xintercept=0, color="blue")
# if you are at the bottom of this, I'd love to work with you in some capacity...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment