Skip to content
Snippets Groups Projects
Commit 09cfcd38 authored by chrysanthopoulou's avatar chrysanthopoulou
Browse files

Add some more minepy matters + let single deltas run

parent 8f6c0855
No related branches found
No related tags found
No related merge requests found
Showing
with 104 additions and 13 deletions
import pandas as pd
import numpy as np
from minepy import MINE
import itertools
# Create a sample DataFrame with numerical data
"""
np.random.seed(0)
data = {
'A': np.random.rand(100),
'B': np.random.rand(100),
'C': np.random.rand(100)
}
"""
df = pd.read_csv(f"../data_overview/single_fic_deltas/call_me_by_your_name/md_freq_dist.csv")
#df = pd.DataFrame(data)
#df = df.head(10)
# Initialize MINE for MIC calculation
mine = MINE(alpha=0.6, c=15)
# Function to calculate MIC and its p-value
def calculate_mic_pvalue(x, y, num_permutations=1000):
mine.compute_score(x, y)
mic_observed = mine.mic()
# Permutation test
greater_count = 0
for _ in range(num_permutations):
y_permuted = np.random.permutation(y)
mine.compute_score(x, y_permuted)
if mine.mic() >= mic_observed:
greater_count += 1
p_value = greater_count / num_permutations
return mic_observed, p_value
# Calculate MIC and p-values for each pair of columns
results = {}
"""
for col1, col2 in itertools.combinations(df.columns, 2):
mic, p_value = calculate_mic_pvalue(df[col1], df[col2])
results[(col1, col2)] = {'MIC': mic, 'p-value': p_value}
"""
for col in df.columns:
mic, p_value = calculate_mic_pvalue(df.index, df[col])
results[("index", col)] = {'MIC': mic, 'p-value': p_value}
results_df = pd.DataFrame(results).T
print(results_df)
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
#!/bin/bash
#SBATCH --job-name=minepy
#SBATCH --output=minepy_1.txt
#SBATCH --output=minepy_3.txt
#SBATCH --mail-user=chrysanthopoulou@cl.uni-heidelberg.de
#SBATCH --mail-type=ALL
#SBATCH --partition=gpushort
#SBATCH --time=20:00
#SBATCH --partition=gpulong
#SBATCH --time=3:00:00
#SBATCH --gres=gpu:4
#SBATCH --ntasks=4
......@@ -14,6 +14,8 @@
#python3 stylo_sing.py
#source fanfic_venv/bin/activate
python3 example_3.py
#deactivate
source ../mic_venv/bin/activate
#cd correlation_with_minepy
python3 example_4.py
deactivate
#python3 fanfic_preprocessing
\ No newline at end of file
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment