Skip to content

Instantly share code, notes, and snippets.

@Ruborcalor
Created May 3, 2020 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ruborcalor/89e30f84d6436f506dcc82e80dd43057 to your computer and use it in GitHub Desktop.
Save Ruborcalor/89e30f84d6436f506dcc82e80dd43057 to your computer and use it in GitHub Desktop.
Methylation: Dimension Reduction Code
# Split data
train_annotated, test_annotated = train_test_split(data_annotated, test_size=0.10)
# Calculate correlation matrix
corr_array = []
for col in train_annotated.columns:
corr_array.append(train_annotated[col].corr(train_annotated["Age"]))
print(len(corr_array))
corr_df = pd.DataFrame(corr_array, columns=["Correlation"], index=train_annotated.columns)
corr_df["Abs_Corr"] = corr_df.Correlation.abs()
corr_df.sort_values("Abs_Corr", inplace=True, ascending=False)
print(corr_df.head(26))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment