Anonymous
Значение формы: почти равны ли общие значения выборки положительной формы общему значению выборки отрицательной формы?
Сообщение
Anonymous » 16 дек 2024, 01:17
Я пишу код для анализа влияния данных TCGA на скрытое пространство.
Вот код:
Код: Выделить всё
test_input1 = tf.convert_to_tensor(tf.random.normal([X_train1.shape[0], n_input1]), dtype=tf.float32)
test_input2 = tf.convert_to_tensor(tf.random.normal([X_train2.shape[0], n_input2]), dtype=tf.float32)
input_tensor1 = tf.keras.Input(shape=(n_input1,))
input_tensor2 = tf.keras.Input(shape=(n_input2,))
combined_input = tf.concat([test_input1, test_input2], axis=1)
self_attention = SelfAttention(units=n_input1 + n_input2)
attention_output = self_attention(combined_input)
encoder = EncoderNetwork(n_input1, n_input2, n_hiddensh, activation=act, _init=func_init)
_ = encoder([test_input1,test_input2])
encoded_output = encoder([input_tensor1, input_tensor2])
wrapped_encoder = tf.keras.Model(inputs=[input_tensor1, input_tensor2], outputs=encoded_output)
load_encoder_weights(encoder, iterator)
load_attention_weights(self_attention, iterator)
self_attention_output = self_attention(combined_input)
test_input1_np = self_attention_output[0].numpy()
test_input2_np = self_attention_output[1].numpy()
explainer = shap.DeepExplainer(wrapped_encoder, [test_input1_np, test_input2_np])
shap_values = explainer.shap_values([test_input1_np, test_input2_np]
shap_values_0 = np.squeeze(shap_values[0])
feature_names_1 = [exp_feature_names[i - 1] for i in htseq_cmt[:, 2].astype(int)]
positive_counts_0 = np.sum(shap_values_0 > 0, axis=0)
negative_counts_0 = np.sum(shap_values_0 < 0, axis=0)
total_samples_0 = shap_values_0.shape[0]
positive_ratios_0 = positive_counts_0 / total_samples_0
negative_ratios_0 = negative_counts_0 / total_samples_0
positive_shap_sums_0 = np.sum(np.where(shap_values_0 > 0, shap_values_0, 0), axis=0)
negative_shap_sums_0 = np.sum(np.where(shap_values_0 < 0, shap_values_0, 0), axis=0)
Ненормальность заключается в том, что разница между значениями положительных и отрицательных значений образцов практически аналогична.
Я не знаю, неверны ли веса и смещения. Или эти данные особенные.
Существует ли какой-либо метод тестирования, позволяющий определить, связан ли аномальный результат с самими данными?
Подробнее здесь:
https://stackoverflow.com/questions/792 ... -the-total
1734301041
Anonymous
Я пишу код для анализа влияния данных TCGA на скрытое пространство. Вот код: [code]test_input1 = tf.convert_to_tensor(tf.random.normal([X_train1.shape[0], n_input1]), dtype=tf.float32) test_input2 = tf.convert_to_tensor(tf.random.normal([X_train2.shape[0], n_input2]), dtype=tf.float32) input_tensor1 = tf.keras.Input(shape=(n_input1,)) input_tensor2 = tf.keras.Input(shape=(n_input2,)) combined_input = tf.concat([test_input1, test_input2], axis=1) self_attention = SelfAttention(units=n_input1 + n_input2) attention_output = self_attention(combined_input) encoder = EncoderNetwork(n_input1, n_input2, n_hiddensh, activation=act, _init=func_init) _ = encoder([test_input1,test_input2]) encoded_output = encoder([input_tensor1, input_tensor2]) wrapped_encoder = tf.keras.Model(inputs=[input_tensor1, input_tensor2], outputs=encoded_output) load_encoder_weights(encoder, iterator) load_attention_weights(self_attention, iterator) self_attention_output = self_attention(combined_input) test_input1_np = self_attention_output[0].numpy() test_input2_np = self_attention_output[1].numpy() explainer = shap.DeepExplainer(wrapped_encoder, [test_input1_np, test_input2_np]) shap_values = explainer.shap_values([test_input1_np, test_input2_np] shap_values_0 = np.squeeze(shap_values[0]) feature_names_1 = [exp_feature_names[i - 1] for i in htseq_cmt[:, 2].astype(int)] positive_counts_0 = np.sum(shap_values_0 > 0, axis=0) negative_counts_0 = np.sum(shap_values_0 < 0, axis=0) total_samples_0 = shap_values_0.shape[0] positive_ratios_0 = positive_counts_0 / total_samples_0 negative_ratios_0 = negative_counts_0 / total_samples_0 positive_shap_sums_0 = np.sum(np.where(shap_values_0 > 0, shap_values_0, 0), axis=0) negative_shap_sums_0 = np.sum(np.where(shap_values_0 < 0, shap_values_0, 0), axis=0) [/code] Ненормальность заключается в том, что разница между значениями положительных и отрицательных значений образцов практически аналогична. [img]https://i.sstatic.net/XFKsB2cg.png[/img] Я не знаю, неверны ли веса и смещения. Или эти данные особенные. Существует ли какой-либо метод тестирования, позволяющий определить, связан ли аномальный результат с самими данными? Подробнее здесь: [url]https://stackoverflow.com/questions/79283263/shap-value-are-the-total-positive-shap-sample-values-almost-equal-to-the-total[/url]