src/tfidf_embdedding_vectorizer.py
def tfidf_embdedding_vectorizer(tweets, test_tweets):
    """
    DESCRIPTION: 
            Given the calculated word embedings (of some dimension d) of the training and test set, 
            this function returns the tweet embeddings of the same d dimension by just averaging the
            vectors of each word in the same tweet and multipliying the corresponding word embedding
            with it's tfidf value.
            This is done for tweets and test_tweets pandas Dataframes.
    INPUT: 
            tweets: Dataframe of a set of tweets as a python strings
            test_tweets: Dataframe of a set of test tweets as a python strings
    OUTPUT: 
            we_tweets: tweet embeddings of d dimension
            we_test_tweets: test tweet embeddings of d dimension
    """
    words = get_embeddings_dictionary(tweets)
    print('building train tfidf')
    algorithm['options']['TFIDF']['tokenizer'] = None
    tfidf = init_tfidf_vectorizer()
    X = tfidf.fit_transform(tweets['tweet'])
    print('train tweets: building (TF-IDF-weighted) WEs')
    we_tweets = average_vectors(tweets, words, tfidf, X)
    print('test tweets: building (TF-IDF-weighted) WEs')
    tfidf = init_tfidf_vectorizer()
    X = tfidf.fit_transform(test_tweets['tweet'])
    we_test_tweets = average_vectors(test_tweets, words, tfidf, X)
    return we_tweets, we_test_tweets

    DESCRIPTION: 
            Given the calculated word embedings (of some dimension d) of the training and test set, 
            this function returns the tweet embeddings of the same d dimension by just averaging the
            vectors of each word in the same tweet and multipliying the corresponding word embedding
            with it's tfidf value.
            This is done for tweets and test_tweets pandas Dataframes.
    INPUT: 
            tweets: Dataframe of a set of tweets as a python strings
            test_tweets: Dataframe of a set of test tweets as a python strings
    OUTPUT: 
            we_tweets: tweet embeddings of d dimension
            we_test_tweets: test tweet embeddings of d dimension
    
Given the calculated word embedings (of some dimension d) of the training and test set,
this function returns the tweet embeddings of the same d dimension by just averaging the
vectors of each word in the same tweet and multipliying the corresponding word embedding
with it's tfidf value.
This is done for tweets and test_tweets pandas Dataframes.
Given the calculated word embedings ( of some dimension d ) of the training and test set this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding with it ' s tfidf value . This is done for tweets and test_tweets pandas Dataframes .
def tfidf_embdedding_vectorizer(tweets, test_tweets):
    words = get_embeddings_dictionary(tweets)
    print('building train tfidf')
    algorithm['options']['TFIDF']['tokenizer'] = None
    tfidf = init_tfidf_vectorizer()
    X = tfidf.fit_transform(tweets['tweet'])
    print('train tweets: building (TF-IDF-weighted) WEs')
    we_tweets = average_vectors(tweets, words, tfidf, X)
    print('test tweets: building (TF-IDF-weighted) WEs')
    tfidf = init_tfidf_vectorizer()
    X = tfidf.fit_transform(test_tweets['tweet'])
    we_test_tweets = average_vectors(test_tweets, words, tfidf, X)
    return we_tweets, we_test_tweets
def tfidf_embdedding_vectorizer ( tweets , test_tweets ) : words = get_embeddings_dictionary ( tweets ) print ( 'building train tfidf' ) algorithm [ 'options' ] [ 'TFIDF' ] [ 'tokenizer' ] = None tfidf = init_tfidf_vectorizer ( ) X = tfidf . fit_transform ( tweets [ 'tweet' ] ) print ( 'train tweets: building (TF-IDF-weighted) WEs' ) we_tweets = average_vectors ( tweets , words , tfidf , X ) print ( 'test tweets: building (TF-IDF-weighted) WEs' ) tfidf = init_tfidf_vectorizer ( ) X = tfidf . fit_transform ( test_tweets [ 'tweet' ] ) we_test_tweets = average_vectors ( test_tweets , words , tfidf , X ) return we_tweets , we_test_tweets
DESCRIPTION:
Given the calculated word embedings (of some dimension d) of the training and test set,
this function returns the tweet embeddings of the same d dimension by just averaging the
vectors of each word in the same tweet and multipliying the corresponding word embedding
with it's tfidf value.
DESCRIPTION : Given the calculated word embedings ( of some dimension d ) of the training and test set this function returns the tweet embeddings of the same d dimension by just averaging the vectors of each word in the same tweet and multipliying the corresponding word embedding with it ' s tfidf value .
"""
    DESCRIPTION: 
            Given the calculated word embedings (of some dimension d) of the training and test set, 
            this function returns the tweet embeddings of the same d dimension by just averaging the
            vectors of each word in the same tweet and multipliying the corresponding word embedding
            with it's tfidf value.
            This is done for tweets and test_tweets pandas Dataframes.
    INPUT: 
            tweets: Dataframe of a set of tweets as a python strings
            test_tweets: Dataframe of a set of test tweets as a python strings
    OUTPUT: 
            we_tweets: tweet embeddings of d dimension
            we_test_tweets: test tweet embeddings of d dimension
    """
tweets
test_tweets