<jupyter_start><jupyter_text>![title](Header__0006_4.png "Header")___ Chapter 4 - Dimensionality Reduction Segment 2 - Explanatory factor analysis<jupyter_code>import pandas as pd
import numpy as np

import sklearn
from sklearn.decomposition import FactorAnalysis

from sklearn import datasets<jupyter_output><empty_output><jupyter_text>Factor analysis on iris dataset<jupyter_code>iris =  datasets.load_iris()

X = iris.data

variable_names = iris.feature_names

X[0:10,]
factor = FactorAnalysis().fit(X)

pd.DataFrame(factor.components_, columns=variable_names)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0893760539629005, 'fraction_numerical': 0.016863406408094434, 'mean_word_length': 8.138461538461538, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '151906', 'license': 'MIT', 'n_tokens_mistral': 208, 'n_tokens_neox': 196, 'n_words': 42, 'path': 'Ch04/04_02/04_02.ipynb', 'repo_name': 'desaiankitb/Python-for-Data-Science-Essential', 'size': '593'}