2017-04-26 53 views
0

如果我想将序列(特征)A,B和C投影到带有张量LSTM的目标序列,我怎么能知道每个特征对目标影响的重要性?主成分分析有帮助吗?如果pca可以帮助,该怎么办?数据的RNN中的主成分分析

的结构(列)设定如下面:

A sequence 
    B sequence 
    C sequence 
    Target sequence 

回答

0

什么将这个序列的主成分是?你可以做的是采取的序列,B序列和C序列的PCA和可视化... 这里是与Tensorboard可视化PCA一个简单的教程:http://www.pinchofintelligence.com/simple-introduction-to-tensorboard-embedding-visualisation/

%matplotlib inline 
import matplotlib.pyplot as plt 
import tensorflow as tf 
import numpy as np 
import os 

from tensorflow.contrib.tensorboard.plugins import projector 
from tensorflow.examples.tutorials.mnist import input_data 

LOG_DIR = 'minimalsample' 
NAME_TO_VISUALISE_VARIABLE = "mnistembedding" 
TO_EMBED_COUNT = 500 


path_for_mnist_sprites = os.path.join(LOG_DIR,'mnistdigits.png') 
path_for_mnist_metadata = os.path.join(LOG_DIR,'metadata.tsv') 
mnist = input_data.read_data_sets("MNIST_data/", one_hot=False) 
batch_xs, batch_ys = mnist.train.next_batch(TO_EMBED_COUNT) 
embedding_var = tf.Variable(batch_xs, name=NAME_TO_VISUALISE_VARIABLE) 
summary_writer = tf.summary.FileWriter(LOG_DIR) 
config = projector.ProjectorConfig() 
embedding = config.embeddings.add() 
embedding.tensor_name = embedding_var.name 

# Specify where you find the metadata 
embedding.metadata_path = path_for_mnist_metadata #'metadata.tsv' 

# Specify where you find the sprite (we will create this later) 
embedding.sprite.image_path = path_for_mnist_sprites #'mnistdigits.png' 
embedding.sprite.single_image_dim.extend([28,28]) 

# Say that you want to visualise the embeddings 
projector.visualize_embeddings(summary_writer, config) 
sess = tf.InteractiveSession() 
sess.run(tf.global_variables_initializer()) 
saver = tf.train.Saver() 
saver.save(sess, os.path.join(LOG_DIR, "model.ckpt"), 1) 
with open(path_for_mnist_metadata,'w') as f: 
    f.write("Index\tLabel\n") 
    for index,label in enumerate(batch_ys): 
     f.write("%d\t%d\n" % (index,label)) 

希望这有助于你想想PCA !

+0

非常感谢。这项工作的主要目的是使用A,B和C预测RNN的目标序列,并定量分析(PCA)A,B,C变量对目标序列的影响。 –