├── Varimax.png ├── Scree-plot.png ├── Thank-you.png ├── LICENSE ├── README.md └── Project-code.ipynb /Varimax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sagar-Darji/Personality-prediction/HEAD/Varimax.png -------------------------------------------------------------------------------- /Scree-plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sagar-Darji/Personality-prediction/HEAD/Scree-plot.png -------------------------------------------------------------------------------- /Thank-you.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sagar-Darji/Personality-prediction/HEAD/Thank-you.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Sagar-Darji 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Personality-prediction 2 | > From the given database `response.csv` Find out the personality traits using this personality prediction project. 3 | 4 | ## Let's get started 5 | [![](https://img.shields.io/badge/author-@SagarDarji-blue.svg?style=flat)](https://www.linkedin.com/in/sagar-darji-7b7011165/) 6 | 7 | The system will predict one's personality and their traits through basic survey.This system will help the human resource to select right candidate for desired job profile, which in turn provide expert workforce for the organization. 8 | 9 | ### Applications in psychology: 10 | Factor analysis has been used in the study of human intelligence and human personality as a method for comparing the outcomes of (hopefully) objective tests and to construct matrices to define correlations between these outcomes, as well as finding the factors for these results. The field of psychology that measures human intelligence using quantitative testing in this way is known as psychometrics (psycho=mental, metrics=measurement). 11 | 12 | ### Advantages: 13 | - Offers a much more objective method of testing traits such as intelligence in humans 14 | - Allows for a satisfactory comparison between the results of intelligence tests 15 | - Provides support for theories that would be difficult to prove otherwise 16 | 17 | ## Algorithm 18 | ```python 19 | Refine the Data 20 | Prepare the Data 21 | Choose the Factor 22 | variable 23 | correlation matrix 24 | using any method of factor analysis such as EFA 25 | Decide no. of factors 26 | factor loading of factors 27 | rotation of factor loadings 28 | provide appropriate no. of factors 29 | 30 | ``` 31 | 32 | ## Now understand and implement the code 33 | > Import all libraries which we needed to perform this `python code` 34 | ```python 35 | #Librerias 36 | import pandas as pd 37 | import numpy as np 38 | import matplotlib.pyplot as plt 39 | ``` 40 | Make Dataframe using `Pandas` and shaped it 41 | ```python 42 | #Data 43 | df = pd.read_csv("responses.csv") 44 | df.shape 45 | ``` 46 | > Out: (1010, 15) 47 | 48 | In `response.csv` [1010 rows, 150 rows] 49 | > Which means this data collected by surveying 1010 individuals and there is 150 types of different prefrence & fields. 50 | 51 | MUSIC PREFERENCES (19) 0:19 52 | 53 | MOVIE PREFERENCES (12) 19:31 54 | 55 | HOBBIES & INTERESTS (32) 31:63 56 | 57 | PHOBIAS (10) 63:73 58 | 59 | HEALTH HABITS (3) 73:76 60 | 61 | PERSONALITY TRAITS, VIEWS ON LIFE & OPINIONS (57) 76:133 62 | 63 | SPENDING HABITS (7) 133:140 64 | 65 | DEMOGRAPHICS (10 ) 140:150 66 | 67 | We will take only: PERSONALITY TRAITS, VIEWS ON LIFE & OPINIONS (57) `76:133` 68 | 69 | 70 | ```python 71 | df = df.iloc[:, 76:133] 72 | df.head(5) 73 | ``` 74 | > Out: 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 |
Daily eventsPrioritising workloadWriting notesWorkaholismThinking aheadFinal judgementReliabilityKeeping promisesLoss of interestFriends versus money...Happiness in lifeEnergy levelsSmall - big dogsPersonalityFinding lost valuablesGetting upInterests or hobbiesParents' adviceQuestionnaires or pollsInternet usage
02.02.05.04.02.05.04.04.01.03.0...4.05.01.04.03.02.03.04.03.0few hours a day
13.02.04.05.04.01.04.04.03.04.0...4.03.05.03.04.05.03.02.03.0few hours a day
21.02.05.03.05.03.04.05.01.05.0...4.04.03.03.03.04.05.03.01.0few hours a day
34.04.04.05.03.01.03.04.05.02.0...2.02.01.02.01.01.0NaN2.04.0most of the day
43.01.02.03.05.05.05.04.02.03.0...3.05.03.03.02.04.03.03.03.0few hours a day
226 |

5 rows × 57 columns

227 | 228 | 229 | 230 | # 1. Prepare the Data 231 | 232 | ```python 233 | #Drop NAs 234 | df = df.dropna() 235 | #............................................................................................... 236 | #Encode categorical data 237 | from sklearn.preprocessing import LabelEncoder 238 | 239 | df = df.apply(LabelEncoder().fit_transform) 240 | df 241 | ``` 242 | 243 | `dropna()` method will remove Null value from dataframe. 244 | 245 | Why are we encoding the data? 246 | > In order to analys data require all i/p & o/p variable to be nummeric. This means that if our data contains categorical dat, we must encode it to number before you can fit and evalute a model. 247 | 248 | There is two type of encoding 249 | 1. `Integer encoding` 250 | > each unique label is mapped to an integer. 251 | 2. `One hot encoding` 252 | > It refers to splitting the column which contains numerical categorical data to many columns depending on the number of categories present in that column. Each column contains “0” or “1” corresponding to which column it has been placed. 253 | 254 | | Before Encoding | After Encoding | 255 | |--------|--------| 256 | | Height | Height | 257 | | Tall | 0 | 258 | | Short | 1 | 259 | | Medium | 2 | 260 | | Medium | 2 | 261 | | Short | 1 | 262 | | Tall | 0 | 263 | 264 | Here, We have used `One hot encoding`. 265 | 266 | > Out: 267 | 268 |
269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 |
Daily eventsPrioritising workloadWriting notesWorkaholismThinking aheadFinal judgementReliabilityKeeping promisesLoss of interestFriends versus money...Happiness in lifeEnergy levelsSmall - big dogsPersonalityFinding lost valuablesGetting upInterests or hobbiesParents' adviceQuestionnaires or pollsInternet usage
01143143302...3403212320
12134303323...3242342120
20142423404...3322234200
42012444312...2422132220
51122202321...2332224230
..................................................................
10052103122233...3222343320
10060204444301...3324202321
10072000302403...2021240342
10082040233342...2113042222
10092434324423...3123011240
563 |

864 rows × 57 columns

564 |
565 | 566 | ## 2. Choose the Factors 567 | 568 | ```python 569 | pip install factor_analyzer 570 | ``` 571 | Requirement already satisfied: factor_analyzer in c:\users\dell\anaconda3\lib\site-packages (0.3.2) 572 | Requirement already satisfied: pandas in c:\users\dell\anaconda3\lib\site-packages (from factor_analyzer) (0.25.1) 573 | Requirement already satisfied: scipy in c:\users\dell\anaconda3\lib\site-packages (from factor_analyzer) (1.3.1) 574 | Requirement already satisfied: numpy in c:\users\dell\anaconda3\lib\site-packages (from factor_analyzer) (1.16.5) 575 | Requirement already satisfied: scikit-learn in c:\users\dell\anaconda3\lib\site-packages (from factor_analyzer) (0.21.3) 576 | Requirement already satisfied: pytz>=2017.2 in c:\users\dell\anaconda3\lib\site-packages (from pandas->factor_analyzer) (2019.3) 577 | Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\dell\anaconda3\lib\site-packages (from pandas->factor_analyzer) (2.8.0) 578 | Requirement already satisfied: joblib>=0.11 in c:\users\dell\anaconda3\lib\site-packages (from scikit-learn->factor_analyzer) (0.13.2) 579 | Requirement already satisfied: six>=1.5 in c:\users\dell\anaconda3\lib\site-packages (from python-dateutil>=2.6.1->pandas->factor_analyzer) (1.12.0) 580 | Note: you may need to restart the kernel to use updated packages. 581 | 582 | `Factor Analyzer` 583 | > Reduce large no. variables into fewer no. of factors. This is a python module to perform exploratory and factor analysis with several optional rotations. It also includes a class to perform confirmatory factor analysis (CFA), with curtain predefined techniques. 584 | 585 | What is Factor Roatation 586 | > minimize the complexity of the factor loadings to make the structure simpler to interpret. 587 | 588 | There is two type of rotation 589 | 1. Orthogonal rotation 590 | > constrain the factors to be uncorrelated. Althogh often favored, In many cases it is unrealistic to expect the factor to be uncorrelated and forcing then to be uncorrelated make it less likely that the rotation produces a solution with simple structure. 591 | Method: 592 | 1. `varimax` 593 | > it maximizes the sum of the variances of the squared loadings and makes the structure simpler. 594 | Mathematical equation of `varimax` 595 | ![png](Varimax.png) 596 | 1. `quatimax` 597 | 1. `equimax` 598 | 4. Oblique rotation 599 | > permit the factors to be correlated with one another often produces solution with a simpler structure. 600 | 601 | Here, Our data is uncorrelated so we have used Orthogonal's `varimax` rotation method. 602 | 603 | Now, We determine no. of factor using Scree plot 604 | > we can use also eigenvalue to determine no. of factor but that is more complex and by Scree plot its is to find. 605 | 606 | ```python 607 | #Try the model with all the variables 608 | from factor_analyzer import FactorAnalyzer # pip install factor_analyzer 609 | fa = FactorAnalyzer(rotation="varimax") 610 | fa.fit(df) 611 | 612 | # Check Eigenvalues 613 | ev, v = fa.get_eigenvalues() 614 | ev 615 | 616 | # Create scree plot using matplotlib 617 | plt.scatter(range(1,df.shape[1]+1),ev) 618 | plt.plot(range(1,df.shape[1]+1),ev) 619 | plt.title('Scree Plot') 620 | plt.xlabel('Factors') 621 | plt.ylabel('Eigenvalue') 622 | plt.grid() 623 | plt.show() 624 | ``` 625 | > Out: 626 | 627 | ![png](Scree-plot.png) 628 | 629 | How we find no. of factor? 630 | > A scree plot shows the eigenvalues on the y-axis and the number of factors on the x-axis. It always displays a downward curve.The point where the slope of the curve is clearly leveling off (the “elbow) indicates the number of factors that should be generated by the analysis. 631 | 632 | As you can see the most usefull factors for explain the data are between 5-6 until falling significantly. 633 | 634 | We will fit the model with 5 Factors: 635 | 636 | ```python 637 | #Factor analysis with 5 fators 638 | fa = FactorAnalyzer(5, rotation="varimax") 639 | fa.fit(df) 640 | AF = fa.loadings_ 641 | AF = pd.DataFrame(AF) 642 | AF.index = df.columns 643 | AF 644 | ``` 645 | > Out: 646 |
647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 |
01234
Daily events0.2504160.0589530.2068770.0260940.028915
Prioritising workload-0.012803-0.1500450.5559460.0789130.128156
Writing notes-0.006039-0.0159270.4208490.2253070.261380
Workaholism0.0695240.0292750.5270820.0885730.032979
Thinking ahead0.0234750.1279090.5304570.0352130.055426
Final judgement0.0461880.1124930.1198610.381338-0.039756
Reliability0.061028-0.1024810.5393730.073534-0.003491
Keeping promises0.053358-0.0346610.4205380.121450-0.033511
Loss of interest0.2737770.2262860.003524-0.1492620.101882
Friends versus money0.021279-0.1118390.0220260.381357-0.045824
Funniness0.3128610.131400-0.043014-0.018258-0.026083
Fake0.0911880.469616-0.024535-0.1917980.019356
Criminal damage0.1548680.177732-0.112659-0.2407210.266761
Decision making-0.2871280.1020330.2674150.1293360.158694
Elections0.074306-0.0155850.2220030.131404-0.083563
Self-criticism-0.0168580.3984200.2291160.1141440.069707
Judgment calls0.182082-0.0104610.1022630.0356750.086474
Hypochondria-0.0402540.258913-0.0348740.0429810.213548
Empathy-0.050152-0.0736970.0594410.3249820.133754
Eating to survive-0.0106080.1830450.003261-0.015131-0.018874
Giving0.082276-0.1545490.1124810.3767230.234000
Compassion to animals-0.083505-0.002767-0.0104240.2621830.192734
Borrowed stuff-0.097017-0.0230470.3232530.1710170.071189
Loneliness-0.1991970.542350-0.0192720.0459420.190369
Cheating in school0.216223-0.063183-0.384634-0.0839400.208210
Health-0.0122670.0278670.1316450.1842960.437826
Changing the past-0.0166220.482307-0.1613200.0738430.159231
God0.0478940.0322810.0271360.453873-0.025963
Dreams0.207076-0.1877230.0786340.037709-0.124853
Charity0.1631610.1168340.1568980.354953-0.067795
Number of friends0.514994-0.321738-0.0867110.241070-0.006859
Punctuality0.0046620.090531-0.1435690.0696480.078111
Lying-0.095933-0.1933700.0017750.1380920.006950
Waiting0.032019-0.067715-0.0008200.075966-0.329606
New environment0.470076-0.129745-0.0589120.005400-0.230743
Mood swings-0.0864770.353226-0.0410050.0314900.404388
Appearence and gestures0.227246-0.0047620.1058940.0688250.303119
Socializing0.537811-0.096245-0.0481270.135323-0.039204
Achievements0.2528350.048658-0.042799-0.0824010.111902
Responding to a serious letter-0.1269850.087976-0.0268760.0229400.013346
Children0.079877-0.1342540.0330400.4401030.075663
Assertiveness0.353462-0.0943720.002509-0.0671850.044117
Getting angry0.0511670.176922-0.086069-0.0708370.532025
Knowing the right people0.4786570.0228680.113503-0.0453590.227230
Public speaking-0.3856740.1046620.0697120.0304470.190834
Unpopularity-0.0821460.2292280.0791730.241031-0.031212
Life struggles-0.2262930.057892-0.0596150.3848750.392060
Happiness in life0.288585-0.5410500.1584730.051235-0.064525
Energy levels0.499978-0.4788600.0379180.122773-0.025001
Small - big dogs0.2066960.040211-0.143225-0.203991-0.131298
Personality0.259646-0.3931970.0642360.049013-0.056988
Finding lost valuables-0.127907-0.0113670.1633540.391951-0.101749
Getting up0.0122170.150551-0.3122970.0825800.121198
Interests or hobbies0.465627-0.2532890.0650150.144827-0.078694
Parents' advice0.022594-0.0328710.2436280.2822520.113225
Questionnaires or polls-0.0451770.1148650.1543090.188501-0.032532
Internet usage-0.0460770.075435-0.007799-0.0815750.048144
1117 |
1118 | 1119 | ```python 1120 | #Get Top variables for each Factor 1121 | F = AF.unstack() 1122 | F = pd.DataFrame(F).reset_index() 1123 | F = F.sort_values(['level_0',0], ascending=False).groupby('level_0').head(5) # Top 5 1124 | F = F.sort_values(by="level_0") 1125 | F.columns=["FACTOR","Variable","Varianza_Explica"] 1126 | F = F.reset_index().drop(["index"],axis=1) 1127 | F 1128 | ``` 1129 | > Out: 1130 |
1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 |
FACTORVariableVarianza_Explica
00New environment0.470076
10Energy levels0.499978
20Number of friends0.514994
30Socializing0.537811
40Knowing the right people0.478657
51Mood swings0.353226
61Self-criticism0.398420
71Fake0.469616
81Changing the past0.482307
91Loneliness0.542350
102Writing notes0.420849
112Workaholism0.527082
122Thinking ahead0.530457
132Prioritising workload0.555946
142Reliability0.539373
153Friends versus money0.381357
163Life struggles0.384875
173Finding lost valuables0.391951
183Children0.440103
193God0.453873
204Appearence and gestures0.303119
214Life struggles0.392060
224Mood swings0.404388
234Health0.437826
244Getting angry0.532025
1293 |
1294 | 1295 | 1296 | ```python 1297 | #Show the Top for each Factor 1298 | F = F.pivot(columns='FACTOR')["Variable"] 1299 | F.apply(lambda x: pd.Series(x.dropna().to_numpy())) 1300 | ``` 1301 | > Out: 1302 |
1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 | 1356 |
FACTOR01234
0New environmentMood swingsWriting notesFriends versus moneyAppearence and gestures
1Energy levelsSelf-criticismWorkaholismLife strugglesLife struggles
2Number of friendsFakeThinking aheadFinding lost valuablesMood swings
3SocializingChanging the pastPrioritising workloadChildrenHealth
4Knowing the right peopleLonelinessReliabilityGodGetting angry
1357 |
1358 | 1359 | --- 1360 | 1361 | FACTOR 1: Energy levels, Number of friends, Socializing... 1362 | 1363 | Could be: Extraversion 1364 | 1365 | --- 1366 | 1367 | FACTOR 2: Self-ciricism, Fake, Loneliness... 1368 | 1369 | Looks very similar to "Neuroticism" 1370 | 1371 | --- 1372 | 1373 | Factor 3: Thinking ahead, Prioritising workload... 1374 | 1375 | very similar to "Conscientiousness" 1376 | 1377 | --- 1378 | 1379 | Factor 4: Children, God, Finding lost valuables 1380 | 1381 | This factor could be something like "religious" or "conservative", maybe have lowest scores of a "Openness" in Big Five model. 1382 | 1383 | --- 1384 | 1385 | Factor 5: Appearence and gestures, Mood swings 1386 | 1387 | Mmmm it could be "Agreeableness". What do you think it could be represent? 1388 | 1389 | --- 1390 | 1391 | ## Conclusion 1392 | The first three Factors are very clear: Extraversion, Neuroticism and Conscientiousness. The other two not to much. Anyway is a very interesting approximation 1393 | 1394 | Maybe doing first a PCA for remove hight correlate variables like "God" and "Final judgement"could help. 1395 | 1396 | What do you think? 1397 | 1398 | # Thank you 1399 | ![png](Thank-you.png) 1400 | > I appreciate especially your `Heart` 1401 | -------------------------------------------------------------------------------- /Project-code.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "#Librerias\n", 10 | "import pandas as pd \n", 11 | "import numpy as np\n", 12 | "import matplotlib.pyplot as plt " 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 4, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "data": { 22 | "text/plain": [ 23 | "(1010, 150)" 24 | ] 25 | }, 26 | "execution_count": 4, 27 | "metadata": {}, 28 | "output_type": "execute_result" 29 | } 30 | ], 31 | "source": [ 32 | "#Data\n", 33 | "df = pd.read_csv(\"responses.csv\")\n", 34 | "df.shape" 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "MUSIC PREFERENCES (19) 0:19\n", 42 | "\n", 43 | "MOVIE PREFERENCES (12) 19:31\n", 44 | "\n", 45 | "HOBBIES & INTERESTS (32) 31:63\n", 46 | "\n", 47 | "PHOBIAS (10) 63:73\n", 48 | "\n", 49 | "HEALTH HABITS (3) 73:76\n", 50 | "\n", 51 | "PERSONALITY TRAITS, VIEWS ON LIFE & OPINIONS (57) 76:133\n", 52 | "\n", 53 | "SPENDING HABITS (7) 133:140\n", 54 | "\n", 55 | "DEMOGRAPHICS (10 ) 140:150\n", 56 | "\n", 57 | "We will take only: PERSONALITY TRAITS, VIEWS ON LIFE & OPINIONS (57) 76:133" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 5, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "data": { 67 | "text/html": [ 68 | "
\n", 69 | "\n", 82 | "\n", 83 | " \n", 84 | " \n", 85 | " \n", 86 | " \n", 87 | " \n", 88 | " \n", 89 | " \n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " \n", 94 | " \n", 95 | " \n", 96 | " \n", 97 | " \n", 98 | " \n", 99 | " \n", 100 | " \n", 101 | " \n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | "
Daily eventsPrioritising workloadWriting notesWorkaholismThinking aheadFinal judgementReliabilityKeeping promisesLoss of interestFriends versus money...Happiness in lifeEnergy levelsSmall - big dogsPersonalityFinding lost valuablesGetting upInterests or hobbiesParents' adviceQuestionnaires or pollsInternet usage
02.02.05.04.02.05.04.04.01.03.0...4.05.01.04.03.02.03.04.03.0few hours a day
13.02.04.05.04.01.04.04.03.04.0...4.03.05.03.04.05.03.02.03.0few hours a day
21.02.05.03.05.03.04.05.01.05.0...4.04.03.03.03.04.05.03.01.0few hours a day
34.04.04.05.03.01.03.04.05.02.0...2.02.01.02.01.01.0NaN2.04.0most of the day
43.01.02.03.05.05.05.04.02.03.0...3.05.03.03.02.04.03.03.03.0few hours a day
\n", 232 | "

5 rows × 57 columns

\n", 233 | "
" 234 | ], 235 | "text/plain": [ 236 | " Daily events Prioritising workload Writing notes Workaholism \\\n", 237 | "0 2.0 2.0 5.0 4.0 \n", 238 | "1 3.0 2.0 4.0 5.0 \n", 239 | "2 1.0 2.0 5.0 3.0 \n", 240 | "3 4.0 4.0 4.0 5.0 \n", 241 | "4 3.0 1.0 2.0 3.0 \n", 242 | "\n", 243 | " Thinking ahead Final judgement Reliability Keeping promises \\\n", 244 | "0 2.0 5.0 4.0 4.0 \n", 245 | "1 4.0 1.0 4.0 4.0 \n", 246 | "2 5.0 3.0 4.0 5.0 \n", 247 | "3 3.0 1.0 3.0 4.0 \n", 248 | "4 5.0 5.0 5.0 4.0 \n", 249 | "\n", 250 | " Loss of interest Friends versus money ... Happiness in life \\\n", 251 | "0 1.0 3.0 ... 4.0 \n", 252 | "1 3.0 4.0 ... 4.0 \n", 253 | "2 1.0 5.0 ... 4.0 \n", 254 | "3 5.0 2.0 ... 2.0 \n", 255 | "4 2.0 3.0 ... 3.0 \n", 256 | "\n", 257 | " Energy levels Small - big dogs Personality Finding lost valuables \\\n", 258 | "0 5.0 1.0 4.0 3.0 \n", 259 | "1 3.0 5.0 3.0 4.0 \n", 260 | "2 4.0 3.0 3.0 3.0 \n", 261 | "3 2.0 1.0 2.0 1.0 \n", 262 | "4 5.0 3.0 3.0 2.0 \n", 263 | "\n", 264 | " Getting up Interests or hobbies Parents' advice Questionnaires or polls \\\n", 265 | "0 2.0 3.0 4.0 3.0 \n", 266 | "1 5.0 3.0 2.0 3.0 \n", 267 | "2 4.0 5.0 3.0 1.0 \n", 268 | "3 1.0 NaN 2.0 4.0 \n", 269 | "4 4.0 3.0 3.0 3.0 \n", 270 | "\n", 271 | " Internet usage \n", 272 | "0 few hours a day \n", 273 | "1 few hours a day \n", 274 | "2 few hours a day \n", 275 | "3 most of the day \n", 276 | "4 few hours a day \n", 277 | "\n", 278 | "[5 rows x 57 columns]" 279 | ] 280 | }, 281 | "execution_count": 5, 282 | "metadata": {}, 283 | "output_type": "execute_result" 284 | } 285 | ], 286 | "source": [ 287 | "df = df.iloc[:, 76:133]\n", 288 | "df.head(5)" 289 | ] 290 | }, 291 | { 292 | "cell_type": "markdown", 293 | "metadata": {}, 294 | "source": [ 295 | "# 1. Prepare the Data" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": 6, 301 | "metadata": {}, 302 | "outputs": [ 303 | { 304 | "data": { 305 | "text/html": [ 306 | "
\n", 307 | "\n", 320 | "\n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 367 | " \n", 368 | " \n", 369 | " \n", 370 | " \n", 371 | " \n", 372 | " \n", 373 | " \n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | " \n", 397 | " \n", 398 | " \n", 399 | " \n", 400 | " \n", 401 | " \n", 402 | " \n", 403 | " \n", 404 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | " \n", 417 | " \n", 418 | " \n", 419 | " \n", 420 | " \n", 421 | " \n", 422 | " \n", 423 | " \n", 424 | " \n", 425 | " \n", 426 | " \n", 427 | " \n", 428 | " \n", 429 | " \n", 430 | " \n", 431 | " \n", 432 | " \n", 433 | " \n", 434 | " \n", 435 | " \n", 436 | " \n", 437 | " \n", 438 | " \n", 439 | " \n", 440 | " \n", 441 | " \n", 442 | " \n", 443 | " \n", 444 | " \n", 445 | " \n", 446 | " \n", 447 | " \n", 448 | " \n", 449 | " \n", 450 | " \n", 451 | " \n", 452 | " \n", 453 | " \n", 454 | " \n", 455 | " \n", 456 | " \n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 488 | " \n", 489 | " \n", 490 | " \n", 491 | " \n", 492 | " \n", 493 | " \n", 494 | " \n", 495 | " \n", 496 | " \n", 497 | " \n", 498 | " \n", 499 | " \n", 500 | " \n", 501 | " \n", 502 | " \n", 503 | " \n", 504 | " \n", 505 | " \n", 506 | " \n", 507 | " \n", 508 | " \n", 509 | " \n", 510 | " \n", 511 | " \n", 512 | " \n", 513 | " \n", 514 | " \n", 515 | " \n", 516 | " \n", 517 | " \n", 518 | " \n", 519 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | " \n", 531 | " \n", 532 | " \n", 533 | " \n", 534 | " \n", 535 | " \n", 536 | " \n", 537 | " \n", 538 | " \n", 539 | " \n", 540 | " \n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | " \n", 547 | " \n", 548 | " \n", 549 | " \n", 550 | " \n", 551 | " \n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | " \n", 605 | " \n", 606 | " \n", 607 | " \n", 608 | " \n", 609 | " \n", 610 | " \n", 611 | " \n", 612 | " \n", 613 | "
Daily eventsPrioritising workloadWriting notesWorkaholismThinking aheadFinal judgementReliabilityKeeping promisesLoss of interestFriends versus money...Happiness in lifeEnergy levelsSmall - big dogsPersonalityFinding lost valuablesGetting upInterests or hobbiesParents' adviceQuestionnaires or pollsInternet usage
01143143302...3403212320
12134303323...3242342120
20142423404...3322234200
42012444312...2422132220
51122202321...2332224230
..................................................................
10052103122233...3222343320
10060204444301...3324202321
10072000302403...2021240342
10082040233342...2113042222
10092434324423...3123011240
\n", 614 | "

864 rows × 57 columns

\n", 615 | "
" 616 | ], 617 | "text/plain": [ 618 | " Daily events Prioritising workload Writing notes Workaholism \\\n", 619 | "0 1 1 4 3 \n", 620 | "1 2 1 3 4 \n", 621 | "2 0 1 4 2 \n", 622 | "4 2 0 1 2 \n", 623 | "5 1 1 2 2 \n", 624 | "... ... ... ... ... \n", 625 | "1005 2 1 0 3 \n", 626 | "1006 0 2 0 4 \n", 627 | "1007 2 0 0 0 \n", 628 | "1008 2 0 4 0 \n", 629 | "1009 2 4 3 4 \n", 630 | "\n", 631 | " Thinking ahead Final judgement Reliability Keeping promises \\\n", 632 | "0 1 4 3 3 \n", 633 | "1 3 0 3 3 \n", 634 | "2 4 2 3 4 \n", 635 | "4 4 4 4 3 \n", 636 | "5 2 0 2 3 \n", 637 | "... ... ... ... ... \n", 638 | "1005 1 2 2 2 \n", 639 | "1006 4 4 4 3 \n", 640 | "1007 3 0 2 4 \n", 641 | "1008 2 3 3 3 \n", 642 | "1009 3 2 4 4 \n", 643 | "\n", 644 | " Loss of interest Friends versus money ... Happiness in life \\\n", 645 | "0 0 2 ... 3 \n", 646 | "1 2 3 ... 3 \n", 647 | "2 0 4 ... 3 \n", 648 | "4 1 2 ... 2 \n", 649 | "5 2 1 ... 2 \n", 650 | "... ... ... ... ... \n", 651 | "1005 3 3 ... 3 \n", 652 | "1006 0 1 ... 3 \n", 653 | "1007 0 3 ... 2 \n", 654 | "1008 4 2 ... 2 \n", 655 | "1009 2 3 ... 3 \n", 656 | "\n", 657 | " Energy levels Small - big dogs Personality Finding lost valuables \\\n", 658 | "0 4 0 3 2 \n", 659 | "1 2 4 2 3 \n", 660 | "2 3 2 2 2 \n", 661 | "4 4 2 2 1 \n", 662 | "5 3 3 2 2 \n", 663 | "... ... ... ... ... \n", 664 | "1005 2 2 2 3 \n", 665 | "1006 3 2 4 2 \n", 666 | "1007 0 2 1 2 \n", 667 | "1008 1 1 3 0 \n", 668 | "1009 1 2 3 0 \n", 669 | "\n", 670 | " Getting up Interests or hobbies Parents' advice \\\n", 671 | "0 1 2 3 \n", 672 | "1 4 2 1 \n", 673 | "2 3 4 2 \n", 674 | "4 3 2 2 \n", 675 | "5 2 4 2 \n", 676 | "... ... ... ... \n", 677 | "1005 4 3 3 \n", 678 | "1006 0 2 3 \n", 679 | "1007 4 0 3 \n", 680 | "1008 4 2 2 \n", 681 | "1009 1 1 2 \n", 682 | "\n", 683 | " Questionnaires or polls Internet usage \n", 684 | "0 2 0 \n", 685 | "1 2 0 \n", 686 | "2 0 0 \n", 687 | "4 2 0 \n", 688 | "5 3 0 \n", 689 | "... ... ... \n", 690 | "1005 2 0 \n", 691 | "1006 2 1 \n", 692 | "1007 4 2 \n", 693 | "1008 2 2 \n", 694 | "1009 4 0 \n", 695 | "\n", 696 | "[864 rows x 57 columns]" 697 | ] 698 | }, 699 | "execution_count": 6, 700 | "metadata": {}, 701 | "output_type": "execute_result" 702 | } 703 | ], 704 | "source": [ 705 | "#Drop NAs\n", 706 | "df = df.dropna()\n", 707 | "#...............................................................................................\n", 708 | "#Encode categorical data\n", 709 | "from sklearn.preprocessing import LabelEncoder\n", 710 | "\n", 711 | "df = df.apply(LabelEncoder().fit_transform)\n", 712 | "df" 713 | ] 714 | }, 715 | { 716 | "cell_type": "markdown", 717 | "metadata": {}, 718 | "source": [ 719 | "# 2. Choose the factors " 720 | ] 721 | }, 722 | { 723 | "cell_type": "code", 724 | "execution_count": 16, 725 | "metadata": {}, 726 | "outputs": [ 727 | { 728 | "name": "stdout", 729 | "output_type": "stream", 730 | "text": [ 731 | "Requirement already satisfied: factor_analyzer in c:\\users\\dell\\anaconda3\\lib\\site-packages (0.3.2)\n", 732 | "Requirement already satisfied: pandas in c:\\users\\dell\\anaconda3\\lib\\site-packages (from factor_analyzer) (0.25.1)\n", 733 | "Requirement already satisfied: scipy in c:\\users\\dell\\anaconda3\\lib\\site-packages (from factor_analyzer) (1.3.1)\n", 734 | "Requirement already satisfied: numpy in c:\\users\\dell\\anaconda3\\lib\\site-packages (from factor_analyzer) (1.16.5)\n", 735 | "Requirement already satisfied: scikit-learn in c:\\users\\dell\\anaconda3\\lib\\site-packages (from factor_analyzer) (0.21.3)\n", 736 | "Requirement already satisfied: pytz>=2017.2 in c:\\users\\dell\\anaconda3\\lib\\site-packages (from pandas->factor_analyzer) (2019.3)\n", 737 | "Requirement already satisfied: python-dateutil>=2.6.1 in c:\\users\\dell\\anaconda3\\lib\\site-packages (from pandas->factor_analyzer) (2.8.0)\n", 738 | "Requirement already satisfied: joblib>=0.11 in c:\\users\\dell\\anaconda3\\lib\\site-packages (from scikit-learn->factor_analyzer) (0.13.2)\n", 739 | "Requirement already satisfied: six>=1.5 in c:\\users\\dell\\anaconda3\\lib\\site-packages (from python-dateutil>=2.6.1->pandas->factor_analyzer) (1.12.0)\n", 740 | "Note: you may need to restart the kernel to use updated packages.\n" 741 | ] 742 | } 743 | ], 744 | "source": [ 745 | "pip install factor_analyzer " 746 | ] 747 | }, 748 | { 749 | "cell_type": "code", 750 | "execution_count": 9, 751 | "metadata": {}, 752 | "outputs": [ 753 | { 754 | "data": { 755 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEWCAYAAABsY4yMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3df3xcdZ3v8dcnv5rQhKaQWGhaGq/UAiJQW3+W1Ra8W1SU+usuXn/ueuUuD3R1lfLDXUV3FbjWu9fVda8PRRdckIpQKxa1cqVRwYdKS+kPKAUUSptCodCUpJ2myeRz/zgn7SSdSSbJnJmcc97PxyOPzJw5M/P9wvQ933y/3/P9mrsjIiLJU1XpAoiISDQU8CIiCaWAFxFJKAW8iEhCKeBFRBJKAS8iklAKeJGImVm7mbmZ1VS6LJIuCniJHTM718x+Z2b7zewFM7vPzF5d4TItNrMBM+sxs24z225mfz2O1/mCmd0cRRklfdSikFgxs+OBNcClwG1AHfAXQO8YX6fG3ftLXLzd7j7LzAy4CLjdzP4AHCzx+4gURS14iZuXA7j7re6edfeMu//S3TcPnmBmHzOzbWFL+mEze1V4/Ekzu9L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ErYtq4Hvu/uUKF2nczOxWYDHB8qV7gGuA1cBtwCnAU8B73X34QOykZmbnAr8FtnC0T/ezBP3wsa2bmZ1FMCBXTdAwus3d/8nM/gtBy/cEYCPwAXfvrVxJxy/sornc3S9MQr3COvw4vFsD/MDdv2xmJxLjz+JYxCrgRUSkeHHqohERkTFQwIuIJJQCXkQkoRTwIiIJpYAXEUkoBbwknpllw9UEB3/ax/EaHzGzmaUvnUh04rRUgch4Zdz9nAm+xkcILpIp+opOM6sOlzcQqQgFvKRS2Ir/T2BqeOjj7v678LErgA8SXKj1c2A9sBC4xcwywOuBNwBfJfg3dD9wqbv3hpf8f4/gqsl/C9dA+VuCZZQfdveLy1E/EVDASzo0hKtAAjzh7u8kWH/kv7r7ITObC9wKLDSztxAsH/tadz9oZie4+wtm9nGCqzzXm1k9wXr+57v7o2b2feBSgqusAQ65+7kAZrYbeGkY/s1lq7EI6oOXdMiEGz6cE4Y7BOu5f8fMtgA/IthEBoI1Zv7D3Q8CFLiEfR7BF8Wj4f2bgDfmPP7DnNubCVr+HyBoxYuUjQJe0urvCdYAOpug+2VwSzpj9KVxR1v7+EDO7bcR7ES2ANiQs0KjSOQU8JJW04Cn3X2AoL+9Ojz+S+BvzOw4CPbvDI93A03h7UeAdjM7Nbz/QeDXw9/AzKqA2e6+jmBDjWagMYK6iOSlgJe0+hpnMRIAAABsSURBVHfgw2b2e+DlhK1ud/8FwXKy68N++8vD828EvhUeM+CvgR+FXTwDwLfyvEc1cHN4zkaCPU67oquSyFBaTVJEJKHUghcRSSgFvIhIQingRUQSSgEvIpJQCngRkYRSwIuIJJQCXkQkof4/mBP4AaZBPCcAAAAASUVORK5CYII=\n", 756 | "text/plain": [ 757 | "
" 758 | ] 759 | }, 760 | "metadata": { 761 | "needs_background": "light" 762 | }, 763 | "output_type": "display_data" 764 | } 765 | ], 766 | "source": [ 767 | "#Try the model with all the variables \n", 768 | "from factor_analyzer import FactorAnalyzer # pip install factor_analyzer \n", 769 | "fa = FactorAnalyzer(rotation=\"varimax\")\n", 770 | "fa.fit(df) \n", 771 | "\n", 772 | "# Check Eigenvalues\n", 773 | "ev, v = fa.get_eigenvalues()\n", 774 | "ev\n", 775 | "\n", 776 | "# Create scree plot using matplotlib\n", 777 | "plt.scatter(range(1,df.shape[1]+1),ev)\n", 778 | "plt.plot(range(1,df.shape[1]+1),ev)\n", 779 | "plt.title('Scree Plot')\n", 780 | "plt.xlabel('Factors')\n", 781 | "plt.ylabel('Eigenvalue')\n", 782 | "plt.grid()\n", 783 | "plt.show()" 784 | ] 785 | }, 786 | { 787 | "cell_type": "code", 788 | "execution_count": 15, 789 | "metadata": {}, 790 | "outputs": [ 791 | { 792 | "data": { 793 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAAzCAQAAAATSZazAAAAAmJLR0QA/4ePzL8AABIGSURBVBgZ7cEJnNUD4gDw73tzNFPTMR06UdNJl2q2FPoXgz/aosixrs3dukKN2y5hXGEt/vytdiWsFWJRK7solKMU5dwc69YWinTN7//5fd7nfWbezJs370X0532/srKysjZHc1k/PblaiYlqrF5RWckNVi7rp6aTs40zWwEamqZQ1mYp9pQiWT81Z7ocDztIaB+3ytos0x0qKx0D5dka7aCZ2goVY64hYmbZT1bGBlskKqt+u7rB1mlbM+RKZqQKcX28pVBWRiIWGC1zIz0p4v+7Ync6THraelpDW6uDXK22fsbL1VvcIybIysjePpEnc209Kl1REeTYGv1RqfTMsrtM5SAi6ofwiDKJSsxyjlvtLa7MJxrKysATLrc5DnOuJoZLR7lZjnOjUlufl+Uq1V59xpotUwUuMseR7tDelreD1xSortTxjne8YlXedoystPUQ6G5z3OIIYyzSQH0a6e8ljHOhrc22ZhvjHBdILc87BsvU9nbxICoc4ocww2nqc4UXZKXtUu+qrZnfypPaEvfpoFg6dvMH/K/9bW0O97ZjNNRAakdaqKZcRyqV2jFOxZN6+iEM82/5UisV6CQrTcvdJlGOv3hEoFAqbczSy1/1F1G/C1xjB9NEbG1uNcgDdjBAaoucKtH57v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N0WyNtv2sn7K8rWUlZX1XfwfqPr5Dqx9aZsAAAAASUVORK5CYII=\n", 794 | "text/plain": [ 795 | "" 796 | ] 797 | }, 798 | "metadata": {}, 799 | "output_type": "display_data" 800 | } 801 | ], 802 | "source": [ 803 | "from IPython.display import display, Image\n", 804 | "display(Image(filename='Varimax.png'))" 805 | ] 806 | }, 807 | { 808 | "cell_type": "markdown", 809 | "metadata": {}, 810 | "source": [ 811 | "As you can see the most usefull factors for explain the data are between 5-6 until falling significantly.\n", 812 | "\n", 813 | "We will fit the model with 5 Factors:" 814 | ] 815 | }, 816 | { 817 | "cell_type": "code", 818 | "execution_count": 18, 819 | "metadata": {}, 820 | "outputs": [ 821 | { 822 | "data": { 823 | "text/html": [ 824 | "
\n", 825 | "\n", 838 | "\n", 839 | " \n", 840 | " \n", 841 | " \n", 842 | " \n", 843 | " \n", 844 | " \n", 845 | " \n", 846 | " \n", 847 | " \n", 848 | " \n", 849 | " \n", 850 | " \n", 851 | " \n", 852 | " \n", 853 | " \n", 854 | " \n", 855 | " \n", 856 | " \n", 857 | " \n", 858 | " \n", 859 | " \n", 860 | " \n", 861 | " \n", 862 | " \n", 863 | " \n", 864 | " \n", 865 | " \n", 866 | " \n", 867 | " \n", 868 | " \n", 869 | " \n", 870 | " \n", 871 | " \n", 872 | " \n", 873 | " \n", 874 | " \n", 875 | " \n", 876 | " \n", 877 | " \n", 878 | " \n", 879 | " \n", 880 | " \n", 881 | " \n", 882 | " \n", 883 | " \n", 884 | " \n", 885 | " \n", 886 | " \n", 887 | " \n", 888 | " \n", 889 | " \n", 890 | " \n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | " \n", 946 | " \n", 947 | " \n", 948 | " \n", 949 | " \n", 950 | " \n", 951 | " \n", 952 | " \n", 953 | " \n", 954 | " \n", 955 | " \n", 956 | " \n", 957 | " \n", 958 | " \n", 959 | " \n", 960 | " \n", 961 | " \n", 962 | " \n", 963 | " \n", 964 | " \n", 965 | " \n", 966 | " \n", 967 | " \n", 968 | " \n", 969 | " \n", 970 | " \n", 971 | " \n", 972 | " \n", 973 | " \n", 974 | " \n", 975 | " \n", 976 | " \n", 977 | " \n", 978 | " \n", 979 | " \n", 980 | " \n", 981 | " \n", 982 | " \n", 983 | " \n", 984 | " \n", 985 | " \n", 986 | " \n", 987 | " \n", 988 | " \n", 989 | " \n", 990 | " \n", 991 | " \n", 992 | " \n", 993 | " \n", 994 | " \n", 995 | " \n", 996 | " \n", 997 | " \n", 998 | " \n", 999 | " \n", 1000 | " \n", 1001 | " \n", 1002 | " \n", 1003 | " \n", 1004 | " \n", 1005 | " \n", 1006 | " \n", 1007 | " \n", 1008 | " \n", 1009 | " \n", 1010 | " \n", 1011 | " \n", 1012 | " \n", 1013 | " \n", 1014 | " \n", 1015 | " \n", 1016 | " \n", 1017 | " \n", 1018 | " \n", 1019 | " \n", 1020 | " \n", 1021 | " \n", 1022 | " \n", 1023 | " \n", 1024 | " \n", 1025 | " \n", 1026 | " \n", 1027 | " \n", 1028 | " \n", 1029 | " \n", 1030 | " \n", 1031 | " \n", 1032 | " \n", 1033 | " \n", 1034 | " \n", 1035 | " \n", 1036 | " \n", 1037 | " \n", 1038 | " \n", 1039 | " \n", 1040 | " \n", 1041 | " \n", 1042 | " \n", 1043 | " \n", 1044 | " \n", 1045 | " \n", 1046 | " \n", 1047 | " \n", 1048 | " \n", 1049 | " \n", 1050 | " \n", 1051 | " \n", 1052 | " \n", 1053 | " \n", 1054 | " \n", 1055 | " \n", 1056 | " \n", 1057 | " \n", 1058 | " \n", 1059 | " \n", 1060 | " \n", 1061 | " \n", 1062 | " \n", 1063 | " \n", 1064 | " \n", 1065 | " \n", 1066 | " \n", 1067 | " \n", 1068 | " \n", 1069 | " \n", 1070 | " \n", 1071 | " \n", 1072 | " \n", 1073 | " \n", 1074 | " \n", 1075 | " \n", 1076 | " \n", 1077 | " \n", 1078 | " \n", 1079 | " \n", 1080 | " \n", 1081 | " \n", 1082 | " \n", 1083 | " \n", 1084 | " \n", 1085 | " \n", 1086 | " \n", 1087 | " \n", 1088 | " \n", 1089 | " \n", 1090 | " \n", 1091 | " \n", 1092 | " \n", 1093 | " \n", 1094 | " \n", 1095 | " \n", 1096 | " \n", 1097 | " \n", 1098 | " \n", 1099 | " \n", 1100 | " \n", 1101 | " \n", 1102 | " \n", 1103 | " \n", 1104 | " \n", 1105 | " \n", 1106 | " \n", 1107 | " \n", 1108 | " \n", 1109 | " \n", 1110 | " \n", 1111 | " \n", 1112 | " \n", 1113 | " \n", 1114 | " \n", 1115 | " \n", 1116 | " \n", 1117 | " \n", 1118 | " \n", 1119 | " \n", 1120 | " \n", 1121 | " \n", 1122 | " \n", 1123 | " \n", 1124 | " \n", 1125 | " \n", 1126 | " \n", 1127 | " \n", 1128 | " \n", 1129 | " \n", 1130 | " \n", 1131 | " \n", 1132 | " \n", 1133 | " \n", 1134 | " \n", 1135 | " \n", 1136 | " \n", 1137 | " \n", 1138 | " \n", 1139 | " \n", 1140 | " \n", 1141 | " \n", 1142 | " \n", 1143 | " \n", 1144 | " \n", 1145 | " \n", 1146 | " \n", 1147 | " \n", 1148 | " \n", 1149 | " \n", 1150 | " \n", 1151 | " \n", 1152 | " \n", 1153 | " \n", 1154 | " \n", 1155 | " \n", 1156 | " \n", 1157 | " \n", 1158 | " \n", 1159 | " \n", 1160 | " \n", 1161 | " \n", 1162 | " \n", 1163 | " \n", 1164 | " \n", 1165 | " \n", 1166 | " \n", 1167 | " \n", 1168 | " \n", 1169 | " \n", 1170 | " \n", 1171 | " \n", 1172 | " \n", 1173 | " \n", 1174 | " \n", 1175 | " \n", 1176 | " \n", 1177 | " \n", 1178 | " \n", 1179 | " \n", 1180 | " \n", 1181 | " \n", 1182 | " \n", 1183 | " \n", 1184 | " \n", 1185 | " \n", 1186 | " \n", 1187 | " \n", 1188 | " \n", 1189 | " \n", 1190 | " \n", 1191 | " \n", 1192 | " \n", 1193 | " \n", 1194 | " \n", 1195 | " \n", 1196 | " \n", 1197 | " \n", 1198 | " \n", 1199 | " \n", 1200 | " \n", 1201 | " \n", 1202 | " \n", 1203 | " \n", 1204 | " \n", 1205 | " \n", 1206 | " \n", 1207 | " \n", 1208 | " \n", 1209 | " \n", 1210 | " \n", 1211 | " \n", 1212 | " \n", 1213 | " \n", 1214 | " \n", 1215 | " \n", 1216 | " \n", 1217 | " \n", 1218 | " \n", 1219 | " \n", 1220 | " \n", 1221 | " \n", 1222 | " \n", 1223 | " \n", 1224 | " \n", 1225 | " \n", 1226 | " \n", 1227 | " \n", 1228 | " \n", 1229 | " \n", 1230 | " \n", 1231 | " \n", 1232 | " \n", 1233 | " \n", 1234 | " \n", 1235 | " \n", 1236 | " \n", 1237 | " \n", 1238 | " \n", 1239 | " \n", 1240 | " \n", 1241 | " \n", 1242 | " \n", 1243 | " \n", 1244 | " \n", 1245 | " \n", 1246 | " \n", 1247 | " \n", 1248 | " \n", 1249 | " \n", 1250 | " \n", 1251 | " \n", 1252 | " \n", 1253 | " \n", 1254 | " \n", 1255 | " \n", 1256 | " \n", 1257 | " \n", 1258 | " \n", 1259 | " \n", 1260 | " \n", 1261 | " \n", 1262 | " \n", 1263 | " \n", 1264 | " \n", 1265 | " \n", 1266 | " \n", 1267 | " \n", 1268 | " \n", 1269 | " \n", 1270 | " \n", 1271 | " \n", 1272 | " \n", 1273 | " \n", 1274 | " \n", 1275 | " \n", 1276 | " \n", 1277 | " \n", 1278 | " \n", 1279 | " \n", 1280 | " \n", 1281 | " \n", 1282 | " \n", 1283 | " \n", 1284 | " \n", 1285 | " \n", 1286 | " \n", 1287 | " \n", 1288 | " \n", 1289 | " \n", 1290 | " \n", 1291 | " \n", 1292 | " \n", 1293 | " \n", 1294 | " \n", 1295 | " \n", 1296 | " \n", 1297 | " \n", 1298 | " \n", 1299 | " \n", 1300 | " \n", 1301 | " \n", 1302 | " \n", 1303 | " \n", 1304 | " \n", 1305 | " \n", 1306 | " \n", 1307 | "
01234
Daily events0.2504160.0589530.2068770.0260940.028915
Prioritising workload-0.012803-0.1500450.5559460.0789130.128156
Writing notes-0.006039-0.0159270.4208490.2253070.261380
Workaholism0.0695240.0292750.5270820.0885730.032979
Thinking ahead0.0234750.1279090.5304570.0352130.055426
Final judgement0.0461880.1124930.1198610.381338-0.039756
Reliability0.061028-0.1024810.5393730.073534-0.003491
Keeping promises0.053358-0.0346610.4205380.121450-0.033511
Loss of interest0.2737770.2262860.003524-0.1492620.101882
Friends versus money0.021279-0.1118390.0220260.381357-0.045824
Funniness0.3128610.131400-0.043014-0.018258-0.026083
Fake0.0911880.469616-0.024535-0.1917980.019356
Criminal damage0.1548680.177732-0.112659-0.2407210.266761
Decision making-0.2871280.1020330.2674150.1293360.158694
Elections0.074306-0.0155850.2220030.131404-0.083563
Self-criticism-0.0168580.3984200.2291160.1141440.069707
Judgment calls0.182082-0.0104610.1022630.0356750.086474
Hypochondria-0.0402540.258913-0.0348740.0429810.213548
Empathy-0.050152-0.0736970.0594410.3249820.133754
Eating to survive-0.0106080.1830450.003261-0.015131-0.018874
Giving0.082276-0.1545490.1124810.3767230.234000
Compassion to animals-0.083505-0.002767-0.0104240.2621830.192734
Borrowed stuff-0.097017-0.0230470.3232530.1710170.071189
Loneliness-0.1991970.542350-0.0192720.0459420.190369
Cheating in school0.216223-0.063183-0.384634-0.0839400.208210
Health-0.0122670.0278670.1316450.1842960.437826
Changing the past-0.0166220.482307-0.1613200.0738430.159231
God0.0478940.0322810.0271360.453873-0.025963
Dreams0.207076-0.1877230.0786340.037709-0.124853
Charity0.1631610.1168340.1568980.354953-0.067795
Number of friends0.514994-0.321738-0.0867110.241070-0.006859
Punctuality0.0046620.090531-0.1435690.0696480.078111
Lying-0.095933-0.1933700.0017750.1380920.006950
Waiting0.032019-0.067715-0.0008200.075966-0.329606
New environment0.470076-0.129745-0.0589120.005400-0.230743
Mood swings-0.0864770.353226-0.0410050.0314900.404388
Appearence and gestures0.227246-0.0047620.1058940.0688250.303119
Socializing0.537811-0.096245-0.0481270.135323-0.039204
Achievements0.2528350.048658-0.042799-0.0824010.111902
Responding to a serious letter-0.1269850.087976-0.0268760.0229400.013346
Children0.079877-0.1342540.0330400.4401030.075663
Assertiveness0.353462-0.0943720.002509-0.0671850.044117
Getting angry0.0511670.176922-0.086069-0.0708370.532025
Knowing the right people0.4786570.0228680.113503-0.0453590.227230
Public speaking-0.3856740.1046620.0697120.0304470.190834
Unpopularity-0.0821460.2292280.0791730.241031-0.031212
Life struggles-0.2262930.057892-0.0596150.3848750.392060
Happiness in life0.288585-0.5410500.1584730.051235-0.064525
Energy levels0.499978-0.4788600.0379180.122773-0.025001
Small - big dogs0.2066960.040211-0.143225-0.203991-0.131298
Personality0.259646-0.3931970.0642360.049013-0.056988
Finding lost valuables-0.127907-0.0113670.1633540.391951-0.101749
Getting up0.0122170.150551-0.3122970.0825800.121198
Interests or hobbies0.465627-0.2532890.0650150.144827-0.078694
Parents' advice0.022594-0.0328710.2436280.2822520.113225
Questionnaires or polls-0.0451770.1148650.1543090.188501-0.032532
Internet usage-0.0460770.075435-0.007799-0.0815750.048144
\n", 1308 | "
" 1309 | ], 1310 | "text/plain": [ 1311 | " 0 1 2 3 \\\n", 1312 | "Daily events 0.250416 0.058953 0.206877 0.026094 \n", 1313 | "Prioritising workload -0.012803 -0.150045 0.555946 0.078913 \n", 1314 | "Writing notes -0.006039 -0.015927 0.420849 0.225307 \n", 1315 | "Workaholism 0.069524 0.029275 0.527082 0.088573 \n", 1316 | "Thinking ahead 0.023475 0.127909 0.530457 0.035213 \n", 1317 | "Final judgement 0.046188 0.112493 0.119861 0.381338 \n", 1318 | "Reliability 0.061028 -0.102481 0.539373 0.073534 \n", 1319 | "Keeping promises 0.053358 -0.034661 0.420538 0.121450 \n", 1320 | "Loss of interest 0.273777 0.226286 0.003524 -0.149262 \n", 1321 | "Friends versus money 0.021279 -0.111839 0.022026 0.381357 \n", 1322 | "Funniness 0.312861 0.131400 -0.043014 -0.018258 \n", 1323 | "Fake 0.091188 0.469616 -0.024535 -0.191798 \n", 1324 | "Criminal damage 0.154868 0.177732 -0.112659 -0.240721 \n", 1325 | "Decision making -0.287128 0.102033 0.267415 0.129336 \n", 1326 | "Elections 0.074306 -0.015585 0.222003 0.131404 \n", 1327 | "Self-criticism -0.016858 0.398420 0.229116 0.114144 \n", 1328 | "Judgment calls 0.182082 -0.010461 0.102263 0.035675 \n", 1329 | "Hypochondria -0.040254 0.258913 -0.034874 0.042981 \n", 1330 | "Empathy -0.050152 -0.073697 0.059441 0.324982 \n", 1331 | "Eating to survive -0.010608 0.183045 0.003261 -0.015131 \n", 1332 | "Giving 0.082276 -0.154549 0.112481 0.376723 \n", 1333 | "Compassion to animals -0.083505 -0.002767 -0.010424 0.262183 \n", 1334 | "Borrowed stuff -0.097017 -0.023047 0.323253 0.171017 \n", 1335 | "Loneliness -0.199197 0.542350 -0.019272 0.045942 \n", 1336 | "Cheating in school 0.216223 -0.063183 -0.384634 -0.083940 \n", 1337 | "Health -0.012267 0.027867 0.131645 0.184296 \n", 1338 | "Changing the past -0.016622 0.482307 -0.161320 0.073843 \n", 1339 | "God 0.047894 0.032281 0.027136 0.453873 \n", 1340 | "Dreams 0.207076 -0.187723 0.078634 0.037709 \n", 1341 | "Charity 0.163161 0.116834 0.156898 0.354953 \n", 1342 | "Number of friends 0.514994 -0.321738 -0.086711 0.241070 \n", 1343 | "Punctuality 0.004662 0.090531 -0.143569 0.069648 \n", 1344 | "Lying -0.095933 -0.193370 0.001775 0.138092 \n", 1345 | "Waiting 0.032019 -0.067715 -0.000820 0.075966 \n", 1346 | "New environment 0.470076 -0.129745 -0.058912 0.005400 \n", 1347 | "Mood swings -0.086477 0.353226 -0.041005 0.031490 \n", 1348 | "Appearence and gestures 0.227246 -0.004762 0.105894 0.068825 \n", 1349 | "Socializing 0.537811 -0.096245 -0.048127 0.135323 \n", 1350 | "Achievements 0.252835 0.048658 -0.042799 -0.082401 \n", 1351 | "Responding to a serious letter -0.126985 0.087976 -0.026876 0.022940 \n", 1352 | "Children 0.079877 -0.134254 0.033040 0.440103 \n", 1353 | "Assertiveness 0.353462 -0.094372 0.002509 -0.067185 \n", 1354 | "Getting angry 0.051167 0.176922 -0.086069 -0.070837 \n", 1355 | "Knowing the right people 0.478657 0.022868 0.113503 -0.045359 \n", 1356 | "Public speaking -0.385674 0.104662 0.069712 0.030447 \n", 1357 | "Unpopularity -0.082146 0.229228 0.079173 0.241031 \n", 1358 | "Life struggles -0.226293 0.057892 -0.059615 0.384875 \n", 1359 | "Happiness in life 0.288585 -0.541050 0.158473 0.051235 \n", 1360 | "Energy levels 0.499978 -0.478860 0.037918 0.122773 \n", 1361 | "Small - big dogs 0.206696 0.040211 -0.143225 -0.203991 \n", 1362 | "Personality 0.259646 -0.393197 0.064236 0.049013 \n", 1363 | "Finding lost valuables -0.127907 -0.011367 0.163354 0.391951 \n", 1364 | "Getting up 0.012217 0.150551 -0.312297 0.082580 \n", 1365 | "Interests or hobbies 0.465627 -0.253289 0.065015 0.144827 \n", 1366 | "Parents' advice 0.022594 -0.032871 0.243628 0.282252 \n", 1367 | "Questionnaires or polls -0.045177 0.114865 0.154309 0.188501 \n", 1368 | "Internet usage -0.046077 0.075435 -0.007799 -0.081575 \n", 1369 | "\n", 1370 | " 4 \n", 1371 | "Daily events 0.028915 \n", 1372 | "Prioritising workload 0.128156 \n", 1373 | "Writing notes 0.261380 \n", 1374 | "Workaholism 0.032979 \n", 1375 | "Thinking ahead 0.055426 \n", 1376 | "Final judgement -0.039756 \n", 1377 | "Reliability -0.003491 \n", 1378 | "Keeping promises -0.033511 \n", 1379 | "Loss of interest 0.101882 \n", 1380 | "Friends versus money -0.045824 \n", 1381 | "Funniness -0.026083 \n", 1382 | "Fake 0.019356 \n", 1383 | "Criminal damage 0.266761 \n", 1384 | "Decision making 0.158694 \n", 1385 | "Elections -0.083563 \n", 1386 | "Self-criticism 0.069707 \n", 1387 | "Judgment calls 0.086474 \n", 1388 | "Hypochondria 0.213548 \n", 1389 | "Empathy 0.133754 \n", 1390 | "Eating to survive -0.018874 \n", 1391 | "Giving 0.234000 \n", 1392 | "Compassion to animals 0.192734 \n", 1393 | "Borrowed stuff 0.071189 \n", 1394 | "Loneliness 0.190369 \n", 1395 | "Cheating in school 0.208210 \n", 1396 | "Health 0.437826 \n", 1397 | "Changing the past 0.159231 \n", 1398 | "God -0.025963 \n", 1399 | "Dreams -0.124853 \n", 1400 | "Charity -0.067795 \n", 1401 | "Number of friends -0.006859 \n", 1402 | "Punctuality 0.078111 \n", 1403 | "Lying 0.006950 \n", 1404 | "Waiting -0.329606 \n", 1405 | "New environment -0.230743 \n", 1406 | "Mood swings 0.404388 \n", 1407 | "Appearence and gestures 0.303119 \n", 1408 | "Socializing -0.039204 \n", 1409 | "Achievements 0.111902 \n", 1410 | "Responding to a serious letter 0.013346 \n", 1411 | "Children 0.075663 \n", 1412 | "Assertiveness 0.044117 \n", 1413 | "Getting angry 0.532025 \n", 1414 | "Knowing the right people 0.227230 \n", 1415 | "Public speaking 0.190834 \n", 1416 | "Unpopularity -0.031212 \n", 1417 | "Life struggles 0.392060 \n", 1418 | "Happiness in life -0.064525 \n", 1419 | "Energy levels -0.025001 \n", 1420 | "Small - big dogs -0.131298 \n", 1421 | "Personality -0.056988 \n", 1422 | "Finding lost valuables -0.101749 \n", 1423 | "Getting up 0.121198 \n", 1424 | "Interests or hobbies -0.078694 \n", 1425 | "Parents' advice 0.113225 \n", 1426 | "Questionnaires or polls -0.032532 \n", 1427 | "Internet usage 0.048144 " 1428 | ] 1429 | }, 1430 | "execution_count": 18, 1431 | "metadata": {}, 1432 | "output_type": "execute_result" 1433 | } 1434 | ], 1435 | "source": [ 1436 | "#Factor analysis with 5 fators\n", 1437 | "fa = FactorAnalyzer(5, rotation=\"varimax\")\n", 1438 | "fa.fit(df)\n", 1439 | "AF = fa.loadings_\n", 1440 | "AF = pd.DataFrame(AF)\n", 1441 | "AF.index = df.columns\n", 1442 | "AF" 1443 | ] 1444 | }, 1445 | { 1446 | "cell_type": "code", 1447 | "execution_count": 19, 1448 | "metadata": {}, 1449 | "outputs": [ 1450 | { 1451 | "data": { 1452 | "text/html": [ 1453 | "
\n", 1454 | "\n", 1467 | "\n", 1468 | " \n", 1469 | " \n", 1470 | " \n", 1471 | " \n", 1472 | " \n", 1473 | " \n", 1474 | " \n", 1475 | " \n", 1476 | " \n", 1477 | " \n", 1478 | " \n", 1479 | " \n", 1480 | " \n", 1481 | " \n", 1482 | " \n", 1483 | " \n", 1484 | " \n", 1485 | " \n", 1486 | " \n", 1487 | " \n", 1488 | " \n", 1489 | " \n", 1490 | " \n", 1491 | " \n", 1492 | " \n", 1493 | " \n", 1494 | " \n", 1495 | " \n", 1496 | " \n", 1497 | " \n", 1498 | " \n", 1499 | " \n", 1500 | " \n", 1501 | " \n", 1502 | " \n", 1503 | " \n", 1504 | " \n", 1505 | " \n", 1506 | " \n", 1507 | " \n", 1508 | " \n", 1509 | " \n", 1510 | " \n", 1511 | " \n", 1512 | " \n", 1513 | " \n", 1514 | " \n", 1515 | " \n", 1516 | " \n", 1517 | " \n", 1518 | " \n", 1519 | " \n", 1520 | " \n", 1521 | " \n", 1522 | " \n", 1523 | " \n", 1524 | " \n", 1525 | " \n", 1526 | " \n", 1527 | " \n", 1528 | " \n", 1529 | " \n", 1530 | " \n", 1531 | " \n", 1532 | " \n", 1533 | " \n", 1534 | " \n", 1535 | " \n", 1536 | " \n", 1537 | " \n", 1538 | " \n", 1539 | " \n", 1540 | " \n", 1541 | " \n", 1542 | " \n", 1543 | " \n", 1544 | " \n", 1545 | " \n", 1546 | " \n", 1547 | " \n", 1548 | " \n", 1549 | " \n", 1550 | " \n", 1551 | " \n", 1552 | " \n", 1553 | " \n", 1554 | " \n", 1555 | " \n", 1556 | " \n", 1557 | " \n", 1558 | " \n", 1559 | " \n", 1560 | " \n", 1561 | " \n", 1562 | " \n", 1563 | " \n", 1564 | " \n", 1565 | " \n", 1566 | " \n", 1567 | " \n", 1568 | " \n", 1569 | " \n", 1570 | " \n", 1571 | " \n", 1572 | " \n", 1573 | " \n", 1574 | " \n", 1575 | " \n", 1576 | " \n", 1577 | " \n", 1578 | " \n", 1579 | " \n", 1580 | " \n", 1581 | " \n", 1582 | " \n", 1583 | " \n", 1584 | " \n", 1585 | " \n", 1586 | " \n", 1587 | " \n", 1588 | " \n", 1589 | " \n", 1590 | " \n", 1591 | " \n", 1592 | " \n", 1593 | " \n", 1594 | " \n", 1595 | " \n", 1596 | " \n", 1597 | " \n", 1598 | " \n", 1599 | " \n", 1600 | " \n", 1601 | " \n", 1602 | " \n", 1603 | " \n", 1604 | " \n", 1605 | " \n", 1606 | " \n", 1607 | " \n", 1608 | " \n", 1609 | " \n", 1610 | " \n", 1611 | " \n", 1612 | " \n", 1613 | " \n", 1614 | " \n", 1615 | " \n", 1616 | " \n", 1617 | " \n", 1618 | " \n", 1619 | " \n", 1620 | " \n", 1621 | " \n", 1622 | " \n", 1623 | " \n", 1624 | " \n", 1625 | " \n", 1626 | " \n", 1627 | " \n", 1628 | "
FACTORVariableVarianza_Explica
00New environment0.470076
10Energy levels0.499978
20Number of friends0.514994
30Socializing0.537811
40Knowing the right people0.478657
51Mood swings0.353226
61Self-criticism0.398420
71Fake0.469616
81Changing the past0.482307
91Loneliness0.542350
102Writing notes0.420849
112Workaholism0.527082
122Thinking ahead0.530457
132Prioritising workload0.555946
142Reliability0.539373
153Friends versus money0.381357
163Life struggles0.384875
173Finding lost valuables0.391951
183Children0.440103
193God0.453873
204Appearence and gestures0.303119
214Life struggles0.392060
224Mood swings0.404388
234Health0.437826
244Getting angry0.532025
\n", 1629 | "
" 1630 | ], 1631 | "text/plain": [ 1632 | " FACTOR Variable Varianza_Explica\n", 1633 | "0 0 New environment 0.470076\n", 1634 | "1 0 Energy levels 0.499978\n", 1635 | "2 0 Number of friends 0.514994\n", 1636 | "3 0 Socializing 0.537811\n", 1637 | "4 0 Knowing the right people 0.478657\n", 1638 | "5 1 Mood swings 0.353226\n", 1639 | "6 1 Self-criticism 0.398420\n", 1640 | "7 1 Fake 0.469616\n", 1641 | "8 1 Changing the past 0.482307\n", 1642 | "9 1 Loneliness 0.542350\n", 1643 | "10 2 Writing notes 0.420849\n", 1644 | "11 2 Workaholism 0.527082\n", 1645 | "12 2 Thinking ahead 0.530457\n", 1646 | "13 2 Prioritising workload 0.555946\n", 1647 | "14 2 Reliability 0.539373\n", 1648 | "15 3 Friends versus money 0.381357\n", 1649 | "16 3 Life struggles 0.384875\n", 1650 | "17 3 Finding lost valuables 0.391951\n", 1651 | "18 3 Children 0.440103\n", 1652 | "19 3 God 0.453873\n", 1653 | "20 4 Appearence and gestures 0.303119\n", 1654 | "21 4 Life struggles 0.392060\n", 1655 | "22 4 Mood swings 0.404388\n", 1656 | "23 4 Health 0.437826\n", 1657 | "24 4 Getting angry 0.532025" 1658 | ] 1659 | }, 1660 | "execution_count": 19, 1661 | "metadata": {}, 1662 | "output_type": "execute_result" 1663 | } 1664 | ], 1665 | "source": [ 1666 | "#Get Top variables for each Factor \n", 1667 | "F = AF.unstack()\n", 1668 | "F = pd.DataFrame(F).reset_index()\n", 1669 | "F = F.sort_values(['level_0',0], ascending=False).groupby('level_0').head(5) # Top 5 \n", 1670 | "F = F.sort_values(by=\"level_0\")\n", 1671 | "F.columns=[\"FACTOR\",\"Variable\",\"Varianza_Explica\"]\n", 1672 | "F = F.reset_index().drop([\"index\"],axis=1)\n", 1673 | "F" 1674 | ] 1675 | }, 1676 | { 1677 | "cell_type": "code", 1678 | "execution_count": 20, 1679 | "metadata": {}, 1680 | "outputs": [ 1681 | { 1682 | "data": { 1683 | "text/html": [ 1684 | "
\n", 1685 | "\n", 1698 | "\n", 1699 | " \n", 1700 | " \n", 1701 | " \n", 1702 | " \n", 1703 | " \n", 1704 | " \n", 1705 | " \n", 1706 | " \n", 1707 | " \n", 1708 | " \n", 1709 | " \n", 1710 | " \n", 1711 | " \n", 1712 | " \n", 1713 | " \n", 1714 | " \n", 1715 | " \n", 1716 | " \n", 1717 | " \n", 1718 | " \n", 1719 | " \n", 1720 | " \n", 1721 | " \n", 1722 | " \n", 1723 | " \n", 1724 | " \n", 1725 | " \n", 1726 | " \n", 1727 | " \n", 1728 | " \n", 1729 | " \n", 1730 | " \n", 1731 | " \n", 1732 | " \n", 1733 | " \n", 1734 | " \n", 1735 | " \n", 1736 | " \n", 1737 | " \n", 1738 | " \n", 1739 | " \n", 1740 | " \n", 1741 | " \n", 1742 | " \n", 1743 | " \n", 1744 | " \n", 1745 | " \n", 1746 | " \n", 1747 | " \n", 1748 | " \n", 1749 | " \n", 1750 | " \n", 1751 | "
FACTOR01234
0New environmentMood swingsWriting notesFriends versus moneyAppearence and gestures
1Energy levelsSelf-criticismWorkaholismLife strugglesLife struggles
2Number of friendsFakeThinking aheadFinding lost valuablesMood swings
3SocializingChanging the pastPrioritising workloadChildrenHealth
4Knowing the right peopleLonelinessReliabilityGodGetting angry
\n", 1752 | "
" 1753 | ], 1754 | "text/plain": [ 1755 | "FACTOR 0 1 2 \\\n", 1756 | "0 New environment Mood swings Writing notes \n", 1757 | "1 Energy levels Self-criticism Workaholism \n", 1758 | "2 Number of friends Fake Thinking ahead \n", 1759 | "3 Socializing Changing the past Prioritising workload \n", 1760 | "4 Knowing the right people Loneliness Reliability \n", 1761 | "\n", 1762 | "FACTOR 3 4 \n", 1763 | "0 Friends versus money Appearence and gestures \n", 1764 | "1 Life struggles Life struggles \n", 1765 | "2 Finding lost valuables Mood swings \n", 1766 | "3 Children Health \n", 1767 | "4 God Getting angry " 1768 | ] 1769 | }, 1770 | "execution_count": 20, 1771 | "metadata": {}, 1772 | "output_type": "execute_result" 1773 | } 1774 | ], 1775 | "source": [ 1776 | "#Show the Top for each Factor \n", 1777 | "F = F.pivot(columns='FACTOR')[\"Variable\"]\n", 1778 | "F.apply(lambda x: pd.Series(x.dropna().to_numpy()))" 1779 | ] 1780 | }, 1781 | { 1782 | "cell_type": "markdown", 1783 | "metadata": {}, 1784 | "source": [ 1785 | "FACTOR 1: Energy levels, Number of friends, Socializing...\n", 1786 | "\n", 1787 | "Could be: Extraversion\n", 1788 | "\n", 1789 | "FACTOR 2: Self-ciricism, Fake, Loneliness...\n", 1790 | "\n", 1791 | "Looks very similar to \"Neuroticism\"\n", 1792 | "\n", 1793 | "Factor 3: Thinking ahead, Prioritising workload...\n", 1794 | "\n", 1795 | "very similar to \"Conscientiousness\"\n", 1796 | "\n", 1797 | "Factor 4: Children, God, Finding lost valuables\n", 1798 | "\n", 1799 | "This factor could be something like \"religious\" or \"conservative\", maybe have lowest scores of a \"Openness\" in Big Five model.\n", 1800 | "\n", 1801 | "Factor 5: Appearence and gestures, Mood swings\n", 1802 | "\n", 1803 | "Mmmm it could be \"Agreeableness\". What do you think it could be represent?" 1804 | ] 1805 | }, 1806 | { 1807 | "cell_type": "markdown", 1808 | "metadata": {}, 1809 | "source": [ 1810 | "# Conclusion:" 1811 | ] 1812 | }, 1813 | { 1814 | "cell_type": "markdown", 1815 | "metadata": {}, 1816 | "source": [ 1817 | "The first three Factors are very clear: Extraversion, Neuroticism and Conscientiousness. The other two not to much. Anyway is a very interesting approximation\n", 1818 | "\n", 1819 | "Maybe doing first a PCA for remove hight correlate variables like \"God\" and \"Final judgement\"could help.\n", 1820 | "\n", 1821 | "What do you think?\n", 1822 | "\n", 1823 | "Thanks you!" 1824 | ] 1825 | } 1826 | ], 1827 | "metadata": { 1828 | "kernelspec": { 1829 | "display_name": "Python 3", 1830 | "language": "python", 1831 | "name": "python3" 1832 | }, 1833 | "language_info": { 1834 | "codemirror_mode": { 1835 | "name": "ipython", 1836 | "version": 3 1837 | }, 1838 | "file_extension": ".py", 1839 | "mimetype": "text/x-python", 1840 | "name": "python", 1841 | "nbconvert_exporter": "python", 1842 | "pygments_lexer": "ipython3", 1843 | "version": "3.7.4" 1844 | } 1845 | }, 1846 | "nbformat": 4, 1847 | "nbformat_minor": 2 1848 | } 1849 | --------------------------------------------------------------------------------