<jupyter_start><jupyter_text>Factor analysis is another technique we can use to reduce dimensionality. However, factor analysis makes assumptions and PCA does not. The basic assumption is that there are implicit features responsible for the features of the dataset.<jupyter_code>data = pd.read_csv('dimensionality_reduction_data.csv')
time_start = time.time()
fa = FactorAnalysis(n_components=2)
fa_results = fa.fit_transform(data)
print('FA done! Time elapsed: {} seconds'.format(time.time()-time_start))<jupyter_output>FA done! Time elapsed: 74.12344217300415 seconds<jupyter_text>t-SNE = 1505 secondsPCA = 0.1 secondsFA = 77 seconds<jupyter_code>data['fa-one'] = fa_results[:,0]
data['fa-two'] = fa_results[:,1]
plt.figure(figsize=(16,10))
sns.scatterplot(
    x="fa-one", y="fa-two",
    palette=sns.color_palette("hls", 10),
    data=data,
    legend="full",
    alpha=0.3
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12981298129812982, 'fraction_numerical': 0.03850385038503851, 'mean_word_length': 6.3983739837398375, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '266588', 'license': 'MIT', 'n_tokens_mistral': 334, 'n_tokens_neox': 307, 'n_words': 72, 'path': 'Section 2/2.3.ipynb', 'repo_name': 'serdarbozoglan/Scikit-learn-Recipes', 'size': '909'}