diff options
author | David Luevano <55825613+luevano@users.noreply.github.com> | 2019-12-28 10:47:20 -0700 |
---|---|---|
committer | David Luevano <55825613+luevano@users.noreply.github.com> | 2019-12-28 10:47:20 -0700 |
commit | cdbb1ac890cb0d062cdb2f216c347f681fbfa7b8 (patch) | |
tree | e7c0bf766e59f8963e994552af4df05522ed8f70 /lj_matrix | |
parent | b4c2dc01ab17248814988c8e141bf16072c45abd (diff) |
Fix bug
Diffstat (limited to 'lj_matrix')
-rw-r--r-- | lj_matrix/__main__.py | 68 | ||||
-rw-r--r-- | lj_matrix/do_ml.py | 4 |
2 files changed, 4 insertions, 68 deletions
diff --git a/lj_matrix/__main__.py b/lj_matrix/__main__.py index 8e52031f1..f7e4065da 100644 --- a/lj_matrix/__main__.py +++ b/lj_matrix/__main__.py @@ -20,76 +20,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import time -from multiprocessing import Process, Pipe -# import matplotlib.pyplot as plt import pandas as pd -from lj_matrix.misc import printc -from lj_matrix.read_qm7_data import read_qm7_data -from lj_matrix.parallel_create_matrices import parallel_create_matrices from lj_matrix.do_ml import do_ml -# Test -def ml(): - """ - Main function that does the whole ML process. - """ - # Initialization time. - init_time = time.perf_counter() - - # Data reading. - molecules, nuclear_charge, energy_pbe0, energy_delta = read_qm7_data() - - # Matrices calculation. - cm_data, ljm_data = parallel_create_matrices(molecules, nuclear_charge) - - # ML calculation. - procs = [] - # cm_pipes = [] - ljm_pipes = [] - for i in range(1500, 6500 + 1, 500): - # cm_recv, cm_send = Pipe(False) - # p1 = Process(target=do_ml, - # args=(cm_data, energy_pbe0, i, 'CM', cm_send)) - # procs.append(p1) - # cm_pipes.append(cm_recv) - # p1.start() - - ljm_recv, ljm_send = Pipe(False) - p2 = Process(target=do_ml, - args=(ljm_data, energy_pbe0, i, 'L-JM', ljm_send)) - procs.append(p2) - ljm_pipes.append(ljm_recv) - p2.start() - - # cm_bench_results = [] - ljm_bench_results = [] - for ljd_pipe in ljm_pipes: # cd_pipe, ljd_pipe in zip(cm_pipes, ljm_pipes): - # cm_bench_results.append(cd_pipe.recv()) - ljm_bench_results.append(ljd_pipe.recv()) - - for proc in procs: - proc.join() - - with open('data\\benchmarks.csv', 'a') as save_file: - # save_file.write(''.join(['ml_type,tr_size,te_size,kernel_s,', - # 'mae,time,lj_s,lj_e,date_ran\n'])) - date = '/'.join([str(field) for field in time.localtime()[:3][::-1]]) - for ljm in ljm_bench_results: # cm, ljm, in zip(cm_bench_results, ljm_bench_results): - # cm_text = ','.join([str(field) for field in cm])\ - # + ',' + date + '\n' - ljm_text = ','.join([str(field) for field in ljm])\ - + ',1,0.25,' + date + '\n' - # save_file.write(cm_text) - save_file.write(ljm_text) - - # End of program - end_time = time.perf_counter() - printc('Program took {:.4f} seconds.'.format(end_time - init_time), - 'CYAN') - - def pl(): """ Function for plotting the benchmarks. @@ -211,6 +145,6 @@ def pl(): if __name__ == '__main__': - ml() + do_ml(min_training_size=1500, max_training_size=3000) # pl() print('OK!') diff --git a/lj_matrix/do_ml.py b/lj_matrix/do_ml.py index 12323780a..8724e6831 100644 --- a/lj_matrix/do_ml.py +++ b/lj_matrix/do_ml.py @@ -113,7 +113,7 @@ def ml(desc_data, def do_ml(min_training_size, max_training_size=None, - training_increment_size=None, + training_increment_size=500, ljm_sigma=1.0, ljm_epsilon=1.0, save_benchmarks=False, @@ -138,6 +138,8 @@ def do_ml(min_training_size, """ # Initialization time. init_time = time.perf_counter() + if not max_training_size: + max_training_size = min_training_size + training_increment_size # Data reading. molecules, nuclear_charge, energy_pbe0, energy_delta = read_qm7_data() |