Skip to content

Commit

Permalink
have basic functionality!
Browse files Browse the repository at this point in the history
  • Loading branch information
lincoln-harris committed Aug 29, 2024
1 parent 08c43ce commit 3d66bc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions lupine/lupine.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def impute(
Path(outpath).mkdir(parents=True, exist_ok=True)
Path(outpath+"/tmp").mkdir(parents=True, exist_ok=True)

fnames = []

# The driver loop for ensemble model
for n_iter in range(0, n_models):
print(f"Fitting model {n_iter+1} of {n_models}")
Expand Down Expand Up @@ -202,25 +204,26 @@ def impute(
# Write.
# These filenames may be helpful for debugging.
outpath_curr = \
outpath + "tmp/qmat_tmp_" + \
outpath + "tmp/lupine_imputed_" + \
str(n_layers_curr) + "layers_" + \
str(prot_factors_curr) + "protFactors_" + \
str(run_factors_curr) + "runFactors_" + \
str(n_nodes_curr) + "nodes_" + \
str(curr_seed) + "seed" + ".csv"

fnames.append(outpath_curr)
model_recon_pd.to_csv(outpath_curr)

# Do the model ensembling
qmats = []
for n_iter in range(0, n_models):
curr_path = outpath + "tmp/qmat_tmp" + str(n_iter) + ".csv"
tmp = pd.read_csv(curr_path)
for fname in fnames:
tmp = pd.read_csv(fname, index_col=0)
qmats.append(tmp)

qmats_mean = np.mean(qmats, axis=0)
outpath_ensemble = outpath + "lupine_recon_quants.csv"
pd.DataFrame(qmats_mean).to_csv(outpath_ensemble)
pd.DataFrame(qmats_mean, index=rows, columns=cols).\
to_csv(outpath_ensemble)
shutil.rmtree(outpath+"tmp")

print(" ")
Expand Down
2 changes: 1 addition & 1 deletion lupine/lupine_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
learning_rate=0.01,
batch_size=128,
tolerance=0.001,
max_epochs=1,
max_epochs=42,
patience=10,
rand_seed=None,
testing=False,
Expand Down

0 comments on commit 3d66bc1

Please sign in to comment.