Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Asking Consumers about their Finances

Kimberly Kreiss Mike Zabek

Federal Reserve Board
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

1 Motivation and Overview

2 Data and Sample

3 Methods

4 References

5 Appendix
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Disclaimer

The views expressed in this presentation are those of the authors

and does not reflect the position of the Federal Reserve Board of

Governors or its staff.
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Motivation and Overview
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

Each year the Federal Reserve conducts the Survey of

Household Economics and Decisionmaking (SHED)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

Each year the Federal Reserve conducts the Survey of

Household Economics and Decisionmaking (SHED)

Nationally representative survey
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

Each year the Federal Reserve conducts the Survey of

Household Economics and Decisionmaking (SHED)

Nationally representative survey

Focuses on the financial lives and experiences of U.S.

individuals and households
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

Each year the Federal Reserve conducts the Survey of

Household Economics and Decisionmaking (SHED)

Nationally representative survey

Focuses on the financial lives and experiences of U.S.

individuals and households

Ask people questions on a range of topics:

Economic Wellbeing

Financial Fragility

Student loans and education

Income and employment

Credit and banking experiences

Housing, neighborhoods, and living situations

Retirement
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

Most of our questions are multiple choice questions, with

the exception of one open-ended response
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

In this year’s survey, we ask respondents to tell us how they

are doing financially, and then we ask them to briefly

explain why they selected that answer:
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

SHED

In this year’s survey, we ask respondents to tell us how they

are doing financially, and then we ask them to briefly

explain why they selected that answer:
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

The Problem

We have over 10,000 write-in responses to our question

It is costly to analyze these data. . .
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

The Problem

We have over 10,000 write-in responses to our question

It is costly to analyze these data. . .

What tools and techniques can we use to systematically

extract information from these write-in responses?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

The Problem

We have over 10,000 write-in responses to our question

It is costly to analyze these data. . .

What tools and techniques can we use to systematically

extract information from these write-in responses?

Why is it important?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Why is this important?

We have a lot of information on consumers’ finances, but

less information on how consumers feel about their finances
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Why is this important?

We have a lot of information on consumers’ finances, but

less information on how consumers feel about their finances

Consumer attitudes and beliefs drive decisionmaking,

decisionmaking affects outcomes
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Why is this important?

We may be able to identify emerging trends or issues that

are not captured in multiple choice data
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Why is this important?

We may be able to identify emerging trends or issues that

are not captured in multiple choice data

We may be able to see cyclical patterns in what people are

talking about
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Why is this important?

We may be able to identify emerging trends or issues that

are not captured in multiple choice data

We may be able to see cyclical patterns in what people are

talking about

We can use responses here to see if the rest of our survey

captures these topics or if we should include new modules
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Why is this important?

We may be able to identify emerging trends or issues that

are not captured in multiple choice data

We may be able to see cyclical patterns in what people are

talking about

We can use responses here to see if the rest of our survey

captures these topics or if we should include new modules

We can collect information on what it means to be doing

well financially or doing poorly financially in the words of

consumers
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Research Question
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Research Question

What circumstances, life events, and attitudes are important for

people when asked to describe why they view their financial

wellbeing in a positive or negative light?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Data and Sample
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Data

We have 11,316 respondents in this year’s survey, just

about all of them tell us how they are doing financially
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Data

0.0

0.1

0.2

0.3

0.4

0.5

Finding it 

 difficult 

 to get by

Just 

 getting by

Doing 

 okay

Living 

 comfortably

Financial wellbeing distribution
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Who answers?

We have a very high response rate for our follow up

open-ended question–over 90% of people write in an answer

Sample size is 10,440 write-in responses
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Who answers?

We have a very high response rate for our follow up

open-ended question–over 90% of people write in an answer

Sample size is 10,440 write-in responses

Median word count is 9, mean word count is 12
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“struggling to get by”?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“struggling to get by”?

“No work in rural community!”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“struggling to get by”?

“No work in rural community!”

“My hospital bills”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“struggling to get by”?

“No work in rural community!”

“My hospital bills”

“Bad job prospects, student loans.”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“struggling to get by”?

“No work in rural community!”

“My hospital bills”

“Bad job prospects, student loans.”

“I am disabled and make $831.00 a month so I have to pick

meds & food vs rent & bills”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“struggling to get by”?

“No work in rural community!”

“My hospital bills”

“Bad job prospects, student loans.”

“I am disabled and make $831.00 a month so I have to pick

meds & food vs rent & bills”

“Single mother of two. My job is not giving me enough

hours . I’ve applied to different job openings and haven’t

heard back.”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“living comfortably”?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“living comfortably”?

“Good job, no debt but the mortgage, and the savings are

growing.”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“living comfortably”?

“Good job, no debt but the mortgage, and the savings are

growing.”

“Two experienced full time wage earners”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“living comfortably”?

“Good job, no debt but the mortgage, and the savings are

growing.”

“Two experienced full time wage earners”

“two good incomes, low credit card debt”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“living comfortably”?

“Good job, no debt but the mortgage, and the savings are

growing.”

“Two experienced full time wage earners”

“two good incomes, low credit card debt”

“We have retirement savings and do not worry about our

finances. House is paid for and pay off credit cards in full.

Travel when we want to without touching any of our

savings.”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

In a sentence or two, please describe why you are

“living comfortably”?

“Good job, no debt but the mortgage, and the savings are

growing.”

“Two experienced full time wage earners”

“two good incomes, low credit card debt”

“We have retirement savings and do not worry about our

finances. House is paid for and pay off credit cards in full.

Travel when we want to without touching any of our

savings.”

“I retired with $1.8 million in investments and a fully

paid-for home.”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Data

Wide range of topics come up across all categories, but how

they are talked about varies substantially:
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Data

Wide range of topics come up across all categories, but how

they are talked about varies substantially:

Income

Debt

Health

Work
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Methods
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Applications

We have a lot of responses, analyzing by hand is

time-consuming
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Applications

We have a lot of responses, analyzing by hand is

time-consuming

What tools can we use to efficiently analyze these

responses?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Tools

Text mining

Simple machine learning and regression models

Natural language processing
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Tools

Text mining

Simple machine learning and regression models

Natural language processing
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Extensions

We have a unique set up with our data: responses that are

labelled with an outcome variable
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Extensions

We have a unique set up with our data: responses that are

labelled with an outcome variable
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Extensions

We have a unique set up with our data: responses that are

labelled with an outcome variable

This allows us to use some simple supervised machine

learning algorithms and regression techniques

Text data in responses are features, outcome is a binary

“doing okay” or “not doing okay”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Machine Learning & Regression techniques

We aren’t really that interested in prediction, why use

machine learning?
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Machine Learning & Regression techniques

We aren’t really that interested in prediction, why use

machine learning?

Certain machine learning algorithms can give information

about feature importance
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Machine Learning & Regression techniques

Random forest

Logistic regression with l1 penalty (Lasso)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Random forest

Ensemble method: aggregated predictions of many different

algorithms to increase accuracy

Random forest is an ensemble method of decision trees
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees

Decision trees are used for both classification and regression

Flowchart with similar structure to a tree, where each node

denotes a decision
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees

Decision trees are used for both classification and regression

Flowchart with similar structure to a tree, where each node

denotes a decision
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees: how a tree decides where to split

Can choose from among several different decision criteria

for deciding when to split
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees: how a tree decides where to split

Can choose from among several different decision criteria

for deciding when to split

Decision trees split on the sub-node that makes the sample

the most homogenous
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees: how a tree decides where to split

Can choose from among several different decision criteria

for deciding when to split

Decision trees split on the sub-node that makes the sample

the most homogenous

We use gini impurity
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees: how a tree decide where to split

You have 4 apples and 4 oranges & want to build a model

that will predict whether the fruit is an apple or orange
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees: how a tree decide where to split

You have 4 apples and 4 oranges & want to build a model

that will predict whether the fruit is an apple or orange
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees

Can be instable
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Decision Trees

Can be instable

Can lead to overfitting
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Random Forest

The idea behind a random forest is to average multiple

decision trees to build a more robust model that is less

susceptible to overfitting
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Random Forest

The idea behind a random forest is to average multiple

decision trees to build a more robust model that is less

susceptible to overfitting

Sou
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Random Forest

1 “Draw a random bootstrap sample of size n

2 Grow a decision tree from the bootstrap sample. At each

node:

1 Randomly select d features without replacement

2 Split the node using the feature that provides the best split

according to the objective function, ie, maximizing

information gain

3 Repeat the steps 1-2k times." (Mirjalili, Raschka, 2017)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Random Forest: feature importance

For each tree, gives a weighted calculation for how much

each split decreases the impurity

Averaged across all the trees

Features with this highest value are the “most important”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Logistic Regression

Used for prediction when the outcome variable is binary

Used to estimate the probability that a particular outcome

will occur
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

l1 penalty (Lasso)

Imposes a penalty that will lead to zero coefficients for

some variables

Generally features not shrunk towards zero can be

interpreted as the more important features
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Interpretation of coefficients

Can be generally hard to interpret

“Expected change in the log odds of not doing okay”

Think about in terms of signs and magnitude in relation to

each other:

Positive coefficient with higher magnitude means that the

presence of that phrase is associated with a higher

probability of not doing okay
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Preprocessing of Data

from nltk.stem import PorterStemmer

#convert to lower case

B2a['B2a'] = B2a['B2a'].apply(lambda x: " ".join(x.lower() for x in x.split()))

# Removing punctuation

# finds any character that is not a word or white space and replaces with ''

B2a['B2a'] = B2a['B2a'].str.replace('[^\w\s]','')

# Stem words

st = PorterStemmer()

B2a['B2a'] = B2a['B2a'].apply(lambda x: " ".join([st.stem(word) for word in x.split()]))
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Preprocessing of data

“Living on Social Security and a small retirement which has not

kept up with the cost of living.”

“live on social secur and a small retir which ha not kept up with

the cost of live”
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Using the model

#split the data into test and training

from sklearn.model_selection import train_test_split

x_train, x_test, y_train, y_test = train_test_split(B2a['B2a'], B2a['not_okay'], \

test_size=.3, random_state=200)

# Initialize a random forest classifier

from sklearn.ensemble import RandomForestClassifier

forest = RandomForestClassifier(n_estimators = 900, max_depth = 100)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Using the model

# Now need to transform the input data into something the model can handle.

# use bag of words

vectorizer = CountVectorizer(analyzer = "word", \

ngram_range = (2,2), \

tokenizer = None, \

preprocessor = None, \

stop_words = None, \

max_features = 500)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Using the model

# transform the training features

vector = vectorizer.fit_transform(x_train)

#make into array for forest.fit()

train_data_features=vector.toarray()

#transform the testing features

vector1 = vectorizer.transform(x_test)

#change test features to numeric input

test_data_features=vector1.toarray()
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Using the model

# transform the training features

vector = vectorizer.fit_transform(x_train)

#make into array for forest.fit()

train_data_features=vector.toarray()

#transform the testing features

vector1 = vectorizer.transform(x_test)

#change test features to numeric input

test_data_features=vector1.toarray()

#train a random forest

rf = forest.fit(train_data_features, y_train) #train the model

y_pred_rf = rf.predict(test_data_features) # use the model on the testing data set

y_pred_score_rf = rf.predict_proba(test_data_features)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Accuracy Metrics

print("Classification Report: ")

print(classification_report(y_test,y_pred))

print("\n")

print("Accuracy : ", accuracy_score(y_test, y_pred) * 100)

print("\n")

print("ROC_AUC : ", roc_auc_score(y_test,y_pred_score[:,1]) * 100)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Accuracy Metrics

print("Classification Report: ")

print(classification_report(y_test,y_pred))

print("\n")

print("Accuracy : ", accuracy_score(y_test, y_pred) * 100)

print("\n")

print("ROC_AUC : ", roc_auc_score(y_test,y_pred_score[:,1]) * 100)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Visualization

## plot feature importances

# get feature importances

importances = forest.feature_importances_

# convert the importances into one-dimensional 1darray

# with corresponding column names as axis labels

f_importances = pd.Series(importances, vectorizer.get_feature_names())

# sort the array in descending order of the importances

f_importances.sort_values(ascending=False, inplace=True)

# make the bar Plot from f_importances

f_importances.plot(x='Features', y='Importance', kind='bar', figsize=(121, 9), rot=90, fontsize=

# show the plot

plt.tight_layout()

plt.show()
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Visualization

Figure 1: Feature Importance
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Lasso Application

# Initialize a logistic classifier

from sklearn.linear_model import LogisticRegression

logistic = LogisticRegression(penalty='l1')

#train a logistic regression

lasso = logistic.fit(train_data_features, y_train)

y_pred_lasso = lasso.predict(test_data_features)

y_pred_score_lasso = lasso.predict_proba(test_data_features)

# Calculate accuracy metrics

accuracy_metrics(y_test, y_pred_lasso, y_pred_score_lasso)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Lasso Application

# Initialize a logistic classifier

from sklearn.linear_model import LogisticRegression

logistic = LogisticRegression(penalty='l1')

#train a logistic regression

lasso = logistic.fit(train_data_features, y_train)

y_pred_lasso = lasso.predict(test_data_features)

y_pred_score_lasso = lasso.predict_proba(test_data_features)

# Calculate accuracy metrics

accuracy_metrics(y_test, y_pred_lasso, y_pred_score_lasso)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Visualization
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Comparison of Results
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Results: disability

Mentioning disability is extremely predictive of poor

financial wellbeing (although there is a low incidence

overall)

Being on disability and not having enough to live on

Work and disability
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Results: health

There seems to be a relationship between health and

financial wellbeing

People talk about not being able to pay medical bills

On the other hand, many mention “good health” as an

important reason for their financial wellbeing (can refer to

both good health or good health insurance)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Results: debt

People value not having any debt

People seem to have aversions to certain types of debt

more than others: people mention high credit card debt for

as an important factor for poor financial wellbeing or not

using credit cards as a sign of good financial wellbeing
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Issues and next step

Does not currently incorporate weights–not nationally

representative

How frequent are each of these across responses? Across

categories?

Likely picking up words that are very common in one

category and not the other (there is still value in that)

Other models or techniques?

Deeper dives on these topics
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Conclusions

One of many ways to analyze text data

Most techniques won’t completely automate analysis for us,

but can give us some information about how to think about

our responses.

Our results suggest some factors that are important for

determining financial wellbeing:

disability/health

debt

income

work
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Questions / comments

Email: kimberly.kreiss@frb.gov

Code:

https://github.com/kimberlykreiss/text_analytics_and_nlp

Slides: https://kimberlykreiss.github.io/

projects_and_code/GASP_slides.pdf
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

References
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

References

Random forest diagram: https://towardsdatascience.com/

random-forest-and-its-implementation-71824ced454f

Mirjalili, Vahid and Sebastian Raschka. Python Machine

Learning United Kingdom: September 2017.
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Appendix
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Text mining

Provides some simple tools that are useful for exploring and

understanding data

Can only paint a simple picture
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Text mining

Word frequency

Bigram network analysis
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Word Frequencies
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Word Frequences by Group
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Bigram Frequency
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Text mining

Helpful for exploring data, but can be somewhat limited in

terms of what we learn

Can get creative with visuals

Can show different visuals by group

Can expand to include dictionary-based sentiment analysis
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Text mining

Used many techniques from Julia Silge’s book Tidy Text

Mining with R found on https://tidytext.com

Code: https:

//github.com/kimberlykreiss/text_analytics_and_nlp
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Nautral Language Processing

Topic modeling (Latent Dirichlet Allocation)
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Natural Language Processing: topic modelling

Unsupervised machine learning technique to identify topics

in documents and words in each topic
Asking

Consumers

about their

Finances

Kimberly

Kreiss, Mike

Zabek

Motivation

and Overview

Data and

Sample

Methods

References

Appendix

Topic models

Don’t work all that well here:

Responses tend to be pretty short, makes it hard for the

model to work

Code/visuals from this soon to be on github page