Skip to content

Commit

Permalink
13. adding of eeg dataset with bayesian tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qnater committed Sep 27, 2024
1 parent 95164ca commit 433cd8d
Show file tree
Hide file tree
Showing 23 changed files with 112 additions and 374 deletions.
62 changes: 32 additions & 30 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified imputegap/assets/contamination/test_contamination.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imputegap/assets/ground_truth/test_ground_truth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imputegap/imputation/__pycache__/imputation.cpython-312.pyc
Binary file not shown.
11 changes: 4 additions & 7 deletions imputegap/imputation/imputation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class Imputation:

@classmethod
def load_parameters(query: str = "default", algorithm: str = "cdrec"):
"""
Load default values of algorithms
Expand All @@ -34,8 +33,6 @@ def load_parameters(query: str = "default", algorithm: str = "cdrec"):
if not os.path.exists(filepath):
filepath = filepath[1:]

print(filepath)

with open(filepath, "r") as _:
config = toml.load(filepath)

Expand Down Expand Up @@ -111,7 +108,7 @@ def cdrec(ground_truth, contamination, params=None):
if params is not None:
truncation_rank, epsilon, iterations = params
else:
truncation_rank, epsilon, iterations = Imputation.load_parameters(algorithm="cdrec")
truncation_rank, epsilon, iterations = Imputation.load_parameters(query="default", algorithm="cdrec")

imputed_matrix = cdrec(contamination=contamination, truncation_rank=truncation_rank, iterations=iterations, epsilon=epsilon)

Expand Down Expand Up @@ -168,7 +165,7 @@ def iim_imputation(ground_truth, contamination, params=None):
if params is not None:
neighbors, algo_code = params
else:
neighbors, algo_code = Imputation.load_parameters(algorithm="iim")
neighbors, algo_code = Imputation.load_parameters(query="default", algorithm="iim")

imputed_matrix = iim(contamination=contamination, number_neighbor=neighbors, algo_code=algo_code)

Expand All @@ -191,7 +188,7 @@ def mrnn_imputation(ground_truth, contamination, params=None):
if params is not None:
hidden_dim, learning_rate, iterations, sequence_length = params
else:
hidden_dim, learning_rate, iterations, sequence_length = Imputation.load_parameters(algorithm="mrnn")
hidden_dim, learning_rate, iterations, sequence_length = Imputation.load_parameters(query="default", algorithm="mrnn")

imputed_matrix = mrnn(contamination=contamination, hidden_dim=hidden_dim, learning_rate=learning_rate, iterations=iterations, sequence_length=sequence_length)

Expand All @@ -216,7 +213,7 @@ def stmvl_imputation(ground_truth, contamination, params=None):
if params is not None:
window_size, gamma, alpha = params
else:
window_size, gamma, alpha = Imputation.load_parameters(algorithm="stmvl")
window_size, gamma, alpha = Imputation.load_parameters(query="default", algorithm="stmvl")

imputed_matrix = stmvl(contamination=contamination, window_size=window_size, gamma=gamma, alpha=alpha)

Expand Down
Binary file added imputegap/manager/__pycache__/utils.cpython-312.pyc
Binary file not shown.
28 changes: 28 additions & 0 deletions imputegap/manager/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os


def get_file_path_dataset(set_name="test"):
"""
Find the accurate path for loading files of tests
:return: correct file paths
"""

filepath = "../imputegap/dataset/" + set_name + ".txt"

if not os.path.exists(filepath):
filepath = filepath[1:]

return filepath


def get_save_path_asset():
"""
Find the accurate path for saving files of tests
:return: correct file paths
"""
filepath = "../tests/assets"

if not os.path.exists(filepath):
filepath = filepath[1:]

return filepath
16 changes: 8 additions & 8 deletions imputegap/runner_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def check_block_size(filename):
gap.print()
gap.plot(ts_type="contamination", title="test", save_path="assets", limitation=3, display=False)

optimal_params, yi = Optimization.Bayesian.bayesian_optimization(ground_truth=gap.ts, contamination=gap.ts_contaminate, algorithm="iim")

print("\nOptical Params : ", optimal_params)
print("\nyi : ", yi, "\n")

Optimization.save_optimization(optimal_params=optimal_params, algorithm="cdrec")

print("\n", "_"*95, "end")
for algo in ["cdrec", "stmvl", "iim", "mrnn"]:
print("RUN OPTIMIZATION FOR : ", algo, "...")
optimal_params, yi = Optimization.Bayesian.bayesian_optimization(ground_truth=gap.ts, contamination=gap.ts_contaminate, algorithm=algo)
print("\nOptical Params : ", optimal_params)
print("\nyi : ", yi, "\n")
Optimization.save_optimization(optimal_params=optimal_params, algorithm=algo)
print("\n", "_"*95, "end")
print("\n", "_" * 95, "end")
Binary file modified tests/__pycache__/test_contamination_mcar.cpython-312.pyc
Binary file not shown.
Binary file modified tests/__pycache__/test_contamination_mp.cpython-312.pyc
Binary file not shown.
Binary file modified tests/__pycache__/test_imputation_iim.cpython-312.pyc
Binary file not shown.
Loading

0 comments on commit 433cd8d

Please sign in to comment.