<jupyter_start><jupyter_text>PCA<jupyter_code>from sklearn.decomposition import PCA

pca = PCA(n_components=8)

principalComponents = pca.fit_transform(smiles_vec)
data = pd.DataFrame(data = principalComponents)
data.head()
data = (data.subtract(data.mean(axis=0), axis=1).div(data.std(ddof=0, axis=0), axis=1))
data = data.div(data.abs().max(axis=0), axis=1)
data.head()
indexed_data = pd.concat([smiles_vec.reset_index()["0"], data], axis =1, ignore_index=True).rename(columns={0: 'smiles'}).set_index('smiles')
transposed = indexed_data.transpose()
transposed[' '] = 0.0000000001
indexed_data = transposed.transpose()
smiles_dict = pd.DataFrame.from_dict(SMILES_CHARACTER_TO_ID, orient='index')
merged_data = pd.merge(right=indexed_data, left=smiles_dict, how="inner",left_index=True, right_index=True)
final = merged_data.values
# pd.set_option('display.float_format', lambda x: '%.5f' % x)
# data.rename(columns=AMINO_ACID_TO_ID).transpose().sort_index()
merged_data
final[0]
np.save("../data/protein/smiles_vec_8.npy", final)
import tensorflow as tf
tf.enable_eager_execution()
embeddings = tf.constant([[ 0.        ,  0.        ,  0.        ],
       [-0.78874256,  0.43069857, -0.47393251],
       [-0.68765258,  0.19845299, -0.64110991],
       [-0.19540625, -0.46831037, -0.43458175],
       [ 0.39009043, -0.46831037, -0.14043892],
       [-0.4217928 ,  0.31515591,  0.5829058 ],
       [-1.        ,  0.43069857, -0.93603945],
       [ 0.088746  , -0.32018371,  0.23223556],
       [ 0.49063027,  0.43069857,  0.32813161],
       [ 0.97943816, -0.1715736 ,  0.46384033],
       [ 0.74644982,  0.43069857,  0.26766763],
       [ 0.45239487,  0.1340585 ,  0.05631338],
       [-0.14891861, -0.26652163, -0.23952655],
       [-0.58491215,  0.43069857,  0.03943025],
       [ 0.3517175 , -0.26652163,  0.0522144 ],
       [ 0.68015679, -1.        ,  0.360837  ],
       [-0.70594505, -0.15329949, -0.60368124],
       [ 0.93336313,  0.00826686, -0.29583345],
       [-0.2963587 ,  0.43069857,  0.16728669],
       [ 0.12175498,  0.01397148,  1.        ],
       [-0.40501324, -0.13937636,  0.21428112]])
embeddings
acid_embeddings = tf.get_variable("acid_embeddings", shape=[21, 3],
                                              initializer=tf.constant_initializer(final[:, :3]), trainable=False)
real_x = tf.nn.embedding_lookup(acid_embeddings, [0,1,2,3,4,5,6])
real_x
emb_distances = tf.matmul(
            tf.nn.l2_normalize(acid_embeddings, axis=1),
            tf.nn.l2_normalize(real_x, axis=1),
            transpose_b=True)

emb_distances
tf.argmax(emb_distances, axis=0)
tf.nn.l2_normalize(acid_embeddings, axis=1) #[-0.78874254,  0.43069857, -0.4739325 ]
a = [[1,2,3],[50,60,70],[800, 900,1000], [-1, -2, -3]]
a = tf.expand_dims(a, axis=0)
a = tf.expand_dims(a, axis=3)
tf.squeeze(a)
x = tf.image.resize_nearest_neighbor(a, [4, 3 * 2])
tf.squeeze(x)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17604418363824645, 'fraction_numerical': 0.20849154297549188, 'mean_word_length': 3.3189269746646795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '297181', 'license': 'MIT', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1235, 'n_words': 170, 'path': 'notebooks/data_analysis/smiles_vec_analysis.ipynb', 'repo_name': 'duttaprat/proteinGAN', 'size': '2897'}