<jupyter_start><jupyter_text><jupyter_code>with open(r"pitchResults/allres3_1558012449.162566.pickled", "rb") as infile:    
    data3 = pickle.load(infile)


figsize(20,10)
for waveform in range(3):
    for i, series in enumerate(data3['res'][waveform]):
        y = array([q for q in series if q != -1])
        x = arange(y.shape[0])
        plot(y, label=str(i))
        
plt.legend()
def convToNan(x):
    return NaN if x == -1 else x

convToNan(0)

d = data3['res']
d = np.vectorize(convToNan)(d)
d.shape
d
import seaborn as sns; sns.set(color_codes=True)
plot(avgAll)

testpitches =arange(-12,13)
import pandas as pd

df = pd.DataFrame(columns=["Waveform", "Frequency", "Relative Pitch", "Reconstruction Error"])
idx=0
for i_freq, freq in enumerate(testFreqs[:5]):
    print(freq)
    for i_note, note in enumerate(arange(-12,13)):
        df.loc[idx] = ["Saw",freq,note,d[0, i_freq, i_note]]
        idx = idx+1
for i_freq, freq in enumerate(testFreqs[:5]):
    print(freq)
    for i_note, note in enumerate(arange(-12,13)):
        df.loc[idx] = ["Square",freq,note,d[1, i_freq, i_note]]
        idx = idx+1
for i_freq, freq in enumerate(testFreqs[:5]):
    print(freq)
    for i_note, note in enumerate(arange(-12,13)):
        df.loc[idx] = ["Triangle",freq,note,d[2, i_freq, i_note]]
        idx = idx+1
            
df
sns.set(style='whitegrid', rc={"grid.linewidth": 0.1})
sns.set_context("paper", font_scale=2)  
figsize(20,5)
sns.lineplot(x='Relative Pitch', y='Reconstruction Error', hue="Waveform", data=df, lw=2)
xlabel("Relative pitch to base frequency (semitones)", fontsize=20)
ylabel("Reconstruction error", fontsize=20)
plt.savefig("tmp/reconPitchSemis.pdf", bbox_inches='tight')
df2 = pd.DataFrame(columns=["Waveform", "Base Frequency", "note", "Reconstruction Error"])
idx=0
for i_wave, wave in enumerate(["Saw", "Square", "Triangle"]):
    print(wave)
    for i_freq, freq in enumerate(testFreqs):
        print(freq)
        for i_note, note in enumerate(arange(-12,13)):
            if (freq * freqMuls[i_note]) < sr/2:
                df2.loc[idx] = [wave,freq,note,d[i_wave, i_freq, i_note]]
            else:
                print("excluding freq: ", freq * freqMuls[i_note])
            
            idx = idx+1
    
figsize(20,4)
sns.boxplot(x='Base Frequency', y='Reconstruction Error',data=df2)
xlabel("Base Frequency (Hz)", fontsize=20)
ylabel("Reconstruction Error", fontsize=20)
plt.savefig("tmp/pitchReconFreq.pdf", bbox_inches='tight')
dPitchRecon = df[["Relative Pitch", "Reconstruction Error"]]
posPitches = dPitchRecon.loc[dPitchRecon["Relative Pitch"] >= 0]

posPitches = posPitches.loc[posPitches["Reconstruction Error"] < 1000000] #remove NaNs

posPitches = array(posPitches)
posPitches
scipy.stats.shapiro(posPitches[:,1])
scipy.stats.pearsonr(posPitches[:,0], posPitches[:,1])
negPitches = dPitchRecon.loc[dPitchRecon["Relative Pitch"] <= 0]

negPitches = negPitches.loc[negPitches["Reconstruction Error"] < 1000000] #remove NaNs

negPitches = array(negPitches)
negPitches
scipy.stats.pearsonr(negPitches[:,0], negPitches[:,1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1600128783000644, 'fraction_numerical': 0.0334835801674179, 'mean_word_length': 4.460456942003515, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '70882', 'license': 'MIT', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1167, 'n_words': 236, 'path': 'Conceptoscillators 1b - Pitch Experiment FInal.ipynb', 'repo_name': 'chriskiefer/conceptorSoundSynthesis', 'size': '3106'}