Skip to content

Commit c72b9c1

Browse files
committed
Created using Colaboratory
1 parent bcdf22a commit c72b9c1

File tree

1 file changed

+64
-34
lines changed

1 file changed

+64
-34
lines changed

FactorAnalysisPersonality.ipynb

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"colab": {
66
"name": "FactorAnalysisPersonality.ipynb",
77
"provenance": [],
8+
"toc_visible": true,
89
"include_colab_link": true
910
},
1011
"kernelspec": {
@@ -24,17 +25,30 @@
2425
]
2526
},
2627
{
27-
"cell_type": "code",
28+
"cell_type": "markdown",
2829
"metadata": {
29-
"id": "_zn3Cg6ECVcW",
30-
"colab_type": "code",
31-
"colab": {}
30+
"id": "qTHBjB_hPxZ1",
31+
"colab_type": "text"
3232
},
3333
"source": [
34-
""
35-
],
36-
"execution_count": 0,
37-
"outputs": []
34+
"# Background on the data"
35+
]
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"metadata": {
40+
"id": "814cvzSKQBjL",
41+
"colab_type": "text"
42+
},
43+
"source": [
44+
"A personality test is given to a large group of people. There are 5 questions which deal with agreeableness (A1-5), 5 questions which deal with conscientiousness (C1-5), 5 questions which deal with Extraversion(E1-5), 5 questions which deal with Neuroticism (N1-5) and 5 questions which deal with Openness (O1-5). \n",
45+
"\n",
46+
"Those answers are directly related with one another.\n",
47+
"\n",
48+
"We want to see if based on people's answers, we can regroup those categories.\n",
49+
"If we can, we will end up with 5 factors and each factor will be influenced by the questions which correspond to it. \n",
50+
"\n"
51+
]
3852
},
3953
{
4054
"cell_type": "markdown",
@@ -71,7 +85,7 @@
7185
"metadata": {
7286
"id": "tP4cR7ZrSuLc",
7387
"colab_type": "code",
74-
"outputId": "d52f563c-c0d0-43ca-a322-8f1885cc7dc8",
88+
"outputId": "611e1c92-4bc6-4193-d21b-5b717b8bf307",
7589
"colab": {
7690
"base_uri": "https://localhost:8080/",
7791
"height": 207
@@ -99,16 +113,16 @@
99113
"gauth.credentials = GoogleCredentials.get_application_default()\n",
100114
"drive = GoogleDrive(gauth)"
101115
],
102-
"execution_count": 0,
116+
"execution_count": 2,
103117
"outputs": [
104118
{
105119
"output_type": "stream",
106120
"text": [
107121
"Collecting factor_analyzer==0.2.3\n",
108122
" Downloading https://files.pythonhosted.org/packages/79/1b/84808bbeee0f3a8753c3d8034baf0aa0013cf08957eff750f366ce83f04a/factor_analyzer-0.2.3-py2.py3-none-any.whl\n",
123+
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from factor_analyzer==0.2.3) (1.16.5)\n",
109124
"Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from factor_analyzer==0.2.3) (0.24.2)\n",
110125
"Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from factor_analyzer==0.2.3) (1.3.1)\n",
111-
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from factor_analyzer==0.2.3) (1.16.5)\n",
112126
"Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/dist-packages (from pandas->factor_analyzer==0.2.3) (2018.9)\n",
113127
"Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python3.6/dist-packages (from pandas->factor_analyzer==0.2.3) (2.5.3)\n",
114128
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/dist-packages (from python-dateutil>=2.5.0->pandas->factor_analyzer==0.2.3) (1.12.0)\n",
@@ -126,7 +140,7 @@
126140
"colab_type": "text"
127141
},
128142
"source": [
129-
"Now we will load the data. This line reads in the comma separated value sheet that I made in excel.\n",
143+
"Now we will load the data. This line reads in the comma separated value sheet.\n",
130144
"\n",
131145
"If you are given sensor data in excel and want to export it to csv in the future, see this link:\n",
132146
"https://www.ablebits.com/office-addins-blog/2014/04/24/convert-excel-csv/"
@@ -175,7 +189,7 @@
175189
"metadata": {
176190
"id": "cbE21AiDU_5L",
177191
"colab_type": "code",
178-
"outputId": "0f51b05e-0763-4115-8322-0d1ff60199f6",
192+
"outputId": "2a0c7e8c-e5f4-4a9e-f4ba-12ef316d9f9e",
179193
"colab": {
180194
"base_uri": "https://localhost:8080/",
181195
"height": 544
@@ -200,7 +214,7 @@
200214
"#calcualte the number of variables\n",
201215
"numVars = df.shape[1]-len(unnecessaryColumns)\n"
202216
],
203-
"execution_count": 0,
217+
"execution_count": 5,
204218
"outputs": [
205219
{
206220
"output_type": "stream",
@@ -288,7 +302,7 @@
288302
"metadata": {
289303
"id": "aXtTewA1WHwR",
290304
"colab_type": "code",
291-
"outputId": "e579ef8c-4963-45a7-e4a2-2041627acdf1",
305+
"outputId": "3b7b6a91-717d-4ad4-e23b-2ee1316d3bb4",
292306
"colab": {
293307
"base_uri": "https://localhost:8080/",
294308
"height": 34
@@ -300,7 +314,7 @@
300314
"chi_square_value,p_value=calculate_bartlett_sphericity(df)\n",
301315
"chi_square_value, p_value"
302316
],
303-
"execution_count": 0,
317+
"execution_count": 6,
304318
"outputs": [
305319
{
306320
"output_type": "execute_result",
@@ -312,7 +326,7 @@
312326
"metadata": {
313327
"tags": []
314328
},
315-
"execution_count": 4
329+
"execution_count": 6
316330
}
317331
]
318332
},
@@ -351,7 +365,7 @@
351365
"metadata": {
352366
"id": "gJbu2WwCXBa0",
353367
"colab_type": "code",
354-
"outputId": "d27d5cbe-3eb2-4dec-f19d-10d268bd818c",
368+
"outputId": "17522ec2-a2c3-4a8c-cb99-97e23c603420",
355369
"colab": {
356370
"base_uri": "https://localhost:8080/",
357371
"height": 34
@@ -364,7 +378,7 @@
364378
"\n",
365379
"kmo_model"
366380
],
367-
"execution_count": 0,
381+
"execution_count": 7,
368382
"outputs": [
369383
{
370384
"output_type": "execute_result",
@@ -376,7 +390,7 @@
376390
"metadata": {
377391
"tags": []
378392
},
379-
"execution_count": 5
393+
"execution_count": 7
380394
}
381395
]
382396
},
@@ -425,7 +439,7 @@
425439
"metadata": {
426440
"id": "Z6zPLCYTXNgL",
427441
"colab_type": "code",
428-
"outputId": "49e91e74-94aa-4158-8d27-7437f971fac9",
442+
"outputId": "37c538c0-50ca-4b5d-b43d-177486fd110f",
429443
"colab": {
430444
"base_uri": "https://localhost:8080/",
431445
"height": 855
@@ -439,7 +453,7 @@
439453
"ev, v = fa.get_eigenvalues()\n",
440454
"ev"
441455
],
442-
"execution_count": 0,
456+
"execution_count": 8,
443457
"outputs": [
444458
{
445459
"output_type": "execute_result",
@@ -608,7 +622,7 @@
608622
"metadata": {
609623
"tags": []
610624
},
611-
"execution_count": 6
625+
"execution_count": 8
612626
}
613627
]
614628
},
@@ -627,7 +641,7 @@
627641
"metadata": {
628642
"id": "8EcInPmvXS4E",
629643
"colab_type": "code",
630-
"outputId": "6050dd3b-4043-4c62-9c88-bcb005c4d5e7",
644+
"outputId": "6589d02c-5353-457b-a17b-c79dd90408d2",
631645
"colab": {
632646
"base_uri": "https://localhost:8080/",
633647
"height": 295
@@ -643,7 +657,7 @@
643657
"plt.grid()\n",
644658
"plt.show()"
645659
],
646-
"execution_count": 0,
660+
"execution_count": 9,
647661
"outputs": [
648662
{
649663
"output_type": "display_data",
@@ -689,7 +703,7 @@
689703
"metadata": {
690704
"id": "es4vNDC1XYdW",
691705
"colab_type": "code",
692-
"outputId": "399e5d49-3f56-4be5-e704-5c7c6f660c6e",
706+
"outputId": "c5735c87-1ad2-4027-ead4-1dfeed33b5a4",
693707
"colab": {
694708
"base_uri": "https://localhost:8080/",
695709
"height": 855
@@ -702,7 +716,7 @@
702716
"fa.analyze(df, numFactors, rotation=\"varimax\")\n",
703717
"fa.loadings"
704718
],
705-
"execution_count": 0,
719+
"execution_count": 10,
706720
"outputs": [
707721
{
708722
"output_type": "execute_result",
@@ -979,7 +993,7 @@
979993
"metadata": {
980994
"tags": []
981995
},
982-
"execution_count": 8
996+
"execution_count": 10
983997
}
984998
]
985999
},
@@ -998,11 +1012,11 @@
9981012
"metadata": {
9991013
"id": "jXtE5F5VaLvW",
10001014
"colab_type": "code",
1001-
"outputId": "ee31f049-282c-443d-9edc-4389d8ac7cf7",
1015+
"outputId": "5ebab41d-9386-42c6-de90-0ed765640d62",
10021016
"cellView": "code",
10031017
"colab": {
10041018
"base_uri": "https://localhost:8080/",
1005-
"height": 102
1019+
"height": 122
10061020
}
10071021
},
10081022
"source": [
@@ -1015,7 +1029,7 @@
10151029
" contributions = [(np.round(factor[x],2),headings[x]) for x in descending if np.abs(factor[x])>factor_threshold]\n",
10161030
" print('Factor %d:'%(i+1),contributions)"
10171031
],
1018-
"execution_count": 0,
1032+
"execution_count": 13,
10191033
"outputs": [
10201034
{
10211035
"output_type": "stream",
@@ -1059,17 +1073,20 @@
10591073
"colab_type": "text"
10601074
},
10611075
"source": [
1062-
"Factor 1 is mostly influenced by the questions about extrovertedness (E); some parts of agreeableness, openness, and nueroticism, influence this, but it is mostly E.\n",
1076+
"Factor 1 is mostly influenced by the questions about extrovertedness (E); some parts of agreeableness, openness, and nueroticism, influence this, but it is mostly E. These were the original E questions.\n",
10631077
"\n",
1064-
"Factor 2 is mostly influenced by neuroticism (N), but smoe parts of extrovertedness and conscientiousness play a role.\n",
1078+
"Factor 2 is mostly influenced by neuroticism (N), but smoe parts of extrovertedness and conscientiousness play a role. These were the original N questions.\n",
10651079
"\n",
10661080
"Factor 3 is mostly influenced by conscientiousness, but extrovertedness can play a role.\n",
1081+
"These were the original C questions.\n",
10671082
"\n",
10681083
"Factor 4 is mostly influenced by openness but extrovertedness plays a role.\n",
1084+
"These were the original O questions.\n",
10691085
"\n",
10701086
"Factor 5 is mostly influenced by agreeableness but extrovertedness plays a role.\n",
1087+
"These were the original A questions.\n",
10711088
"\n",
1072-
"In summary, extrovertedness played a role in all of the factors so it is dominanting the system. However looking at individual factors, we can see that specific traits influence specific factors. "
1089+
"In summary, we were able to extract the original groupings however it was interesting to note the role that E plays in all of the questions. This could suggest that there is some bias or systematic error at play. "
10731090
]
10741091
},
10751092
{
@@ -1082,6 +1099,19 @@
10821099
"# Computing the variance"
10831100
]
10841101
},
1102+
{
1103+
"cell_type": "code",
1104+
"metadata": {
1105+
"id": "bxzTgYfzRvsp",
1106+
"colab_type": "code",
1107+
"colab": {}
1108+
},
1109+
"source": [
1110+
""
1111+
],
1112+
"execution_count": 0,
1113+
"outputs": []
1114+
},
10851115
{
10861116
"cell_type": "code",
10871117
"metadata": {

0 commit comments

Comments
 (0)