Skip to content

Encoding

KenWWW edited this page Jul 11, 2023 · 7 revisions

Explanation

Script: tfsplt_encoding.py

Makefile target: plot-encoding

This is the main plotting script. It can plot different line colors, line styles, horizontal or vertical subplots.


Example

Below is a full example of a Makefile target and its arguments. Here, we are plotting the probable/improbable results using glove embeddings for all subjects. We split into subplots by keys (comprehension and production). Lines are colored by labels and styled by keys

# Arguments
LAGS_PLT := {-10000..10000..25} # lag10k-25
LAGS_SHOW := {-2000..2000..25}
X_VALS_SHOW := {-2000..2000..25}
LAG_TKS := 
LAG_TK_LABLS :=
PLT_PARAMS := --lc-by labels --ls-by keys --split horizontal --split-by keys # plot for prod+comp (247 plots)
Y_LIMIT := 0
FIG_SZ:= 18 6
SIG_FN_DIR := 'data/plotting/sig-elecs/20230510-tfs-sig-file'
SIG_FN := --sig-elec-file tfs-sig-file-glove-625-comp.csv tfs-sig-file-glove-625-prod.csv tfs-sig-file-glove-676-comp.csv tfs-sig-file-glove-676-prod.csv tfs-sig-file-glove-7170-comp.csv tfs-sig-file-glove-7170-prod.csv tfs-sig-file-glove-798-comp.csv tfs-sig-file-glove-798-prod.csv
plot-encoding:
	rm -f results/figures/*
	python scripts/tfsplt_encoding.py \
		--sid 625 676 7170 798 \
		--formats \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-625-glove50-lag10k-25-gpt2-xl-prob/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-625-glove50-lag10k-25-gpt2-xl-improb/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-676-glove50-lag10k-25-gpt2-xl-prob/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-676-glove50-lag10k-25-gpt2-xl-improb/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-7170-glove50-lag10k-25-gpt2-xl-prob/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-7170-glove50-lag10k-25-gpt2-xl-improb/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-798-glove50-lag10k-25-gpt2-xl-prob/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-798-glove50-lag10k-25-gpt2-xl-improb/*/*_%s.csv' \
		--labels prob improb prob improb prob improb prob improb \
		--keys comp prod \
		--sig-elec-file-dir $(SIG_FN_DIR)\
		$(SIG_FN) \
		--fig-size $(FIG_SZ) \
		--lags-plot $(LAGS_PLT) \
		--lags-show $(LAGS_SHOW) \
		--x-vals-show $(X_VALS_SHOW) \
		$(LAG_TKS) \
		$(LAG_TK_LABLS) \
		$(PLT_PARAMS) \
		--y-vals-limit $(Y_LIMIT) \
		--outfile results/figures/tfs-glove-probimprob.pdf
	rsync -av results/figures/ ~/tigress/247-encoding-results/

Example Simplified

Below is a simplified version of the previous example. Notice how we can simplify both SIG_FN and formats using %s as a placeholder for sid. Similarly, the labels are simplified along with formats.

# Arguments
LAGS_PLT := {-10000..10000..25} # lag10k-25
LAGS_SHOW := {-2000..2000..25}
X_VALS_SHOW := {-2000..2000..25}
LAG_TKS := 
LAG_TK_LABLS :=
PLT_PARAMS := --lc-by labels --ls-by keys --split horizontal --split-by keys # plot for prod+comp (247 plots)
Y_LIMIT := 0
FIG_SZ:= 18 6
SIG_FN_DIR := 'data/plotting/sig-elecs/20230510-tfs-sig-file'
SIG_FN := --sig-elec-file tfs-sig-file-glove-%s-comp.csv tfs-sig-file-glove-%s-prod.csv
plot-encoding:
	rm -f results/figures/*
	python scripts/tfsplt_encoding.py \
		--sid 625 676 7170 798 \
		--formats \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-%s-glove50-lag10k-25-gpt2-xl-prob/*/*_%s.csv' \
			'/projects/HASSON/247/ken-encoding/demo/20230227-gpt2-preds/kw-tfs-full-%s-glove50-lag10k-25-gpt2-xl-improb/*/*_%s.csv' \
		--labels prob improb \
		--keys comp prod \
		--sig-elec-file-dir $(SIG_FN_DIR)\
		$(SIG_FN) \
		--fig-size $(FIG_SZ) \
		--lags-plot $(LAGS_PLT) \
		--lags-show $(LAGS_SHOW) \
		--x-vals-show $(X_VALS_SHOW) \
		$(LAG_TKS) \
		$(LAG_TK_LABLS) \
		$(PLT_PARAMS) \
		--y-vals-limit $(Y_LIMIT) \
		--outfile results/figures/tfs-glove-probimprob.pdf
	rsync -av results/figures/ ~/tigress/247-encoding-results/

Clone this wiki locally