Skip to content

3.1 trial experiment

import sys, os
import warnings
import tqdm
import random
import pandas as pd
import numpy as np

import matplotlib.pyplot as plt

# Insert path to model directory,.
cwd = os.getcwd()
path = f"{cwd}/../../src"
sys.path.insert(0, path)

# toy datasets
from data.toy import RBIGData

# Experiments
from experiments.distributions import DistributionExp

# Kernel Dependency measure
from models.dependence import HSIC, train_rbf_hsic
from models.kernel import estimate_sigma, sigma_to_gamma, gamma_to_sigma, get_param_grid

# RBIG IT measures
from models.ite_algorithms import run_rbig_models

import scipy.io as scio

import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

warnings.filterwarnings('ignore') # get rid of annoying warnings

%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
float('0.1')
0.1

Trial Experiment

I am basically just testing the script that I use on the SLURM server before I send it off to the batch processing.

SAVE_PATH = "/home/emmanuel/projects/2019_hsic_align/results/hsic/"

clf_exp = DistributionExp(
    seed=123,
    factor=1,
    sigma_est='median',
    n_gamma=10,
    save_path=SAVE_PATH,
    save_name='dist_v1_gamma',
)

# run full experiment
clf_exp.run_experiment()
Function: gauss
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-23-937e854bdd0b> in <module>
     11 
     12 # run full experiment
---> 13 clf_exp.run_experiment()

~/projects/2019_hsic_align/notebooks/4_distributions/../../src/experiments/distributions.py in run_experiment(self)
    214                                             hsic_method=hsic_method,
    215                                             hsic_score=hsic_score,
--> 216                                             mi_score=mi_score,
    217                                         )
    218 

~/projects/2019_hsic_align/notebooks/4_distributions/../../src/experiments/distributions.py in append_results(self, results_df, dataset, trial, n_samples, d_dimensions, std, nu, gamma, gamma_init, hsic_method, hsic_score, mi_score)
    337                 "mi_score": mi_score,
    338             },
--> 339             ignore_index=True,
    340         )
    341 

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/frame.py in append(self, other, ignore_index, verify_integrity, sort)
   7121             ignore_index=ignore_index,
   7122             verify_integrity=verify_integrity,
-> 7123             sort=sort,
   7124         )
   7125 

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy)
    253         verify_integrity=verify_integrity,
    254         copy=copy,
--> 255         sort=sort,
    256     )
    257 

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/reshape/concat.py in __init__(self, objs, axis, join, join_axes, keys, levels, names, ignore_index, verify_integrity, copy, sort)
    333 
    334             # consolidate
--> 335             obj._consolidate(inplace=True)
    336             ndims.add(obj.ndim)
    337 

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/generic.py in _consolidate(self, inplace)
   5268         inplace = validate_bool_kwarg(inplace, "inplace")
   5269         if inplace:
-> 5270             self._consolidate_inplace()
   5271         else:
   5272             f = lambda: self._data.consolidate()

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/generic.py in _consolidate_inplace(self)
   5250             self._data = self._data.consolidate()
   5251 
-> 5252         self._protect_consolidate(f)
   5253 
   5254     def _consolidate(self, inplace=False):

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/generic.py in _protect_consolidate(self, f)
   5239         """
   5240         blocks_before = len(self._data.blocks)
-> 5241         result = f()
   5242         if len(self._data.blocks) != blocks_before:
   5243             self._clear_item_cache()

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/generic.py in f()
   5248 
   5249         def f():
-> 5250             self._data = self._data.consolidate()
   5251 
   5252         self._protect_consolidate(f)

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/internals/managers.py in consolidate(self)
    930         bm = self.__class__(self.blocks, self.axes)
    931         bm._is_consolidated = False
--> 932         bm._consolidate_inplace()
    933         return bm
    934 

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/internals/managers.py in _consolidate_inplace(self)
    935     def _consolidate_inplace(self):
    936         if not self.is_consolidated():
--> 937             self.blocks = tuple(_consolidate(self.blocks))
    938             self._is_consolidated = True
    939             self._known_consolidated = True

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/internals/managers.py in _consolidate(blocks)
   1911     for (_can_consolidate, dtype), group_blocks in grouper:
   1912         merged_blocks = _merge_blocks(
-> 1913             list(group_blocks), dtype=dtype, _can_consolidate=_can_consolidate
   1914         )
   1915         new_blocks = _extend_blocks(merged_blocks, new_blocks)

~/.conda/envs/it4dnn/lib/python3.6/site-packages/pandas/core/internals/blocks.py in _merge_blocks(blocks, dtype, _can_consolidate)
   3321 
   3322         argsort = np.argsort(new_mgr_locs)
-> 3323         new_values = new_values[argsort]
   3324         new_mgr_locs = new_mgr_locs[argsort]
   3325 

KeyboardInterrupt: