<jupyter_start><jupyter_text>Multicollinearity means that the predictor variables are correlated. One way of checking for this issue is exemplified in the following post:https://stackoverflow.com/questions/25676145/capturing-high-multi-collinearity-in-statsmodels?rq=1This post uses the Eigen vectors and values<jupyter_code>import numpy as np
xs = np.random.randn(100, 5)      # independent variables
corr = np.corrcoef(xs, rowvar=0)  # correlation matrix
 w, v = np.linalg.eig(corr) # eigen values & eigen vectors
print(w)<jupyter_output>[ 0.78668234  0.87166262  1.20602515  1.10245121  1.03317868]<jupyter_text>We see that none of the eigen values are close to 0, this means that there is no collinearity Now, let's create a predictor variable that is correlated with the rest:<jupyter_code>noise = np.random.randn(100)                      # white noise
xs[:,4] = 2 * xs[:,0] + 3 * xs[:,2] + .5 * noise  # collinearity
corr = np.corrcoef(xs, rowvar=0)
w, v = np.linalg.eig(corr)
w<jupyter_output><empty_output><jupyter_text>One the eigen values (the second one) is close to 0 which means that there is collinearity And the corresponding eigen vector is:<jupyter_code>v[:,1]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09933774834437085, 'fraction_numerical': 0.059602649006622516, 'mean_word_length': 4.955665024630542, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '12821', 'license': 'Apache-2.0', 'n_tokens_mistral': 458, 'n_tokens_neox': 401, 'n_words': 124, 'path': 'MACHINE_LEARNING/Checking for multicollinearity.ipynb', 'repo_name': 'elowy01/PYTHON_NOTES', 'size': '1208'}