Created
January 5, 2022 12:12
-
-
Save EvanGertis/a82faad87e13adf2a8ef11e57d27f1c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_correlation(s): | |
s_temp = s[['A1','A3']] | |
correlation = s_temp.corr().iloc[1,0] | |
print("******************************") | |
print(f'Correlation between A1 & A3: {correlation}') | |
print("******************************") | |
# if correlation > 0.6 or correlation < 0.6 remove A3 | |
if correlation > 0.6 or correlation < -0.6: | |
s = s.drop(['A3'], axis=1) | |
print(f'A3 was removed {correlation} > 0.6 or {correlation} < -0.6') | |
print("******************************") | |
return | |
def df_to_array(df): | |
A1 = df[['A1']].to_numpy() | |
A2 = df[['A2']].to_numpy() | |
if 'A3' in df: | |
A3 = df[['A3']].to_numpy() | |
df_as_matrix = np.array(A1,A2) | |
if 'A3' in s: | |
df_as_matrix = np.concatenate(df_as_matrix,A3) | |
return df_as_matrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment