Skip to content
Snippets Groups Projects
Commit 24a0c493 authored by Julian Linke's avatar Julian Linke
Browse files

no .eps and argument ERROR

parent 3ae7fe6b
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path): ...@@ -35,7 +35,7 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
A = np.load(pcaA_path) A = np.load(pcaA_path)
b = np.load(pcab_path) b = np.load(pcab_path)
print('\nspkIDs:\n{}'.format(spks)) print('\nspkIDs:\n{}'.format(spks))
print('\ninput matrix:\n{}'.format(X)) print('\ninput matrix X:\n{}'.format(X))
labels = list(spks) labels = list(spks)
fig, ax = plt.subplots(figsize=(15,15)) fig, ax = plt.subplots(figsize=(15,15))
...@@ -45,7 +45,7 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path): ...@@ -45,7 +45,7 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
plt.yticks(range(len(labels)), labels); plt.yticks(range(len(labels)), labels);
fig.colorbar(cax, ticks=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, .8, .9, 1]) fig.colorbar(cax, ticks=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, .8, .9, 1])
fig_path = os.path.join(out_path,'{}.png'.format(X_path.split('/')[-1].replace('.npy',''))) fig_path = os.path.join(out_path,'{}.png'.format(X_path.split('/')[-1].replace('.npy','')))
print('\nsave fig {}'.format(fig_path)) print('\nsave similarity matrix to {}'.format(fig_path))
plt.savefig(fig_path) plt.savefig(fig_path)
colordict = {} colordict = {}
...@@ -56,7 +56,6 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path): ...@@ -56,7 +56,6 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
spks_tmp = corpora[corpus] spks_tmp = corpora[corpus]
for spk in spks_tmp: for spk in spks_tmp:
colordict[corpus].append(colors[idx]) colordict[corpus].append(colors[idx])
print(colordict)
col = sum([lst for lst in colordict.values()], []) col = sum([lst for lst in colordict.values()], [])
print("\nProject with PCA (3 dimensions) ...") print("\nProject with PCA (3 dimensions) ...")
...@@ -82,14 +81,12 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path): ...@@ -82,14 +81,12 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
ax.legend(loc='center left', bbox_to_anchor=(1.175, .5)) ax.legend(loc='center left', bbox_to_anchor=(1.175, .5))
# Save the plot # Save the plot
fig_path = os.path.join(out_path,'scatter3D_{}.png'.format(X_path.split('/')[-1].replace('.npy',''))) fig_path = os.path.join(out_path,'scatter3D_{}.png'.format(X_path.split('/')[-1].replace('.npy','')))
print('\nsave fig {}'.format(fig_path)) print('\nsave 3D scatter plot {}'.format(fig_path))
plt.savefig(fig_path) plt.savefig(fig_path)
fig_path = os.path.join(out_path,'scatter3D_{}.eps'.format(X_path.split('/')[-1].replace('.npy','')))
print('save fig {}'.format(fig_path))
plt.savefig(fig_path, format='eps')
plt.rcParams.update({'font.size': 50}) plt.rcParams.update({'font.size': 50})
for proj in [(0, 1), (0, 2), (1, 2)]: for proj in [(0, 1), (0, 2), (1, 2)]:
print(f"\nProject on dimensions {proj}")
x, y = X_proj[:,proj[0]], X_proj[:,proj[1]] x, y = X_proj[:,proj[0]], X_proj[:,proj[1]]
fig, ax = plt.subplots(figsize=(18,16)) fig, ax = plt.subplots(figsize=(18,16))
...@@ -109,11 +106,8 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path): ...@@ -109,11 +106,8 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
plt.grid() plt.grid()
plt.tight_layout() plt.tight_layout()
fig_path = os.path.join(out_path,'scatter_proj{}_{}.png'.format(''.join([str(proj[0]),str(proj[1])]), X_path.split('/')[-1].replace('.npy',''))) fig_path = os.path.join(out_path,'scatter_proj{}_{}.png'.format(''.join([str(proj[0]),str(proj[1])]), X_path.split('/')[-1].replace('.npy','')))
print('\nsave fig {}'.format(fig_path)) print('save 2D scatter plot {}'.format(fig_path))
plt.savefig(fig_path) plt.savefig(fig_path)
fig_path = os.path.join(out_path,'scatter_proj{}_{}.eps'.format(''.join([str(proj[0]),str(proj[1])]), X_path.split('/')[-1].replace('.npy','')))
print('save fig {}'.format(fig_path))
plt.savefig(fig_path, format='eps')
if __name__ == "__main__": if __name__ == "__main__":
############################# FEATURES PATH ########################### ############################# FEATURES PATH ###########################
......
...@@ -8,8 +8,8 @@ set -e -o pipefail ...@@ -8,8 +8,8 @@ set -e -o pipefail
. path.sh . path.sh
. conda.sh . conda.sh
if [[ $# -eq 0 ]] ; then if [[ $# -eq 1 ]] ; then
echo 'ERROR: this run-script requires an argument: stage=?' echo 'ERROR: this run-script requires two arguments: DATA=? stage=?'
exit 1 exit 1
fi fi
...@@ -82,7 +82,7 @@ if [ $stage == 4 ] || [ $stage == 0 ]; then ...@@ -82,7 +82,7 @@ if [ $stage == 4 ] || [ $stage == 0 ]; then
$exp_dir/numpy/similarity_matrix.npy \ $exp_dir/numpy/similarity_matrix.npy \
--output $exp_dir/numpy/pca \ --output $exp_dir/numpy/pca \
--dim 3 --dim 3
printf "\n... PLOT ...\n" printf "\n... PLOT similarity in PCA space (Analysis) ...\n"
python3 local/plot_pca_similarities.py \ python3 local/plot_pca_similarities.py \
$exp_dir/numpy/similarity_matrix.npy \ $exp_dir/numpy/similarity_matrix.npy \
$exp_dir/numpy/splits_labels.npy \ $exp_dir/numpy/splits_labels.npy \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment