(infile_name, outfile_name=None, vector_size=100, window=10, min_count=3, n_jobs=1,
                         method='skip-gram', **kwargs)
return model
Trains word2vec (Mol2vec, ProtVec) model on corpus file extracted from molecule/protein sequences.
    The corpus file is treated as LineSentence corpus (one sentence = one line, words separated by whitespaces)
    
    Parameters
    ----------
    infile_name : str
        Corpus file, e.g. proteins split in n-grams or compound identifier
    outfile_name : str
        Name of output file where word2vec model should be saved
    vector_size : int
        Number of dimensions of vector
    window : int
        Number of words considered as context
    min_count : int
        Number of occurrences a word should have to be considered in training
    n_jobs : int
        Number of cpu cores used for calculation
    method : str
        Method to use in model training. Options cbow and skip-gram, default: skip-gram)
    
    Returns
    -------
    word2vec.Word2Vec
Trains word2vec (Mol2vec, ProtVec) model on corpus file extracted from molecule/protein sequences.
    The corpus file is treated as LineSentence corpus (one sentence = one line, words separated by whitespaces)
    
    Parameters
    ----------
    infile_name : str
        Corpus file, e.g. proteins split in n-grams or compound identifier
    outfile_name : str
        Name of output file where word2vec model should be saved
    vector_size : int
        Number of dimensions of vector
    window : int
        Number of words considered as context
    min_count : int
        Number of occurrences a word should have to be considered in training
    n_jobs : int
        Number of cpu cores used for calculation
    method : str
        Method to use in model training. Options cbow and skip-gram, default: skip-gram)
    
    Returns
    -------
    word2vec.Word2Vec
Trains word2vec ( Mol2vec ProtVec ) model on corpus file extracted from molecule / protein sequences . The corpus file is treated as LineSentence corpus ( one sentence = one line words separated by whitespaces ) Parameters ---------- infile_name : str Corpus file e . g . proteins split in n - grams or compound identifier outfile_name : str Name of output file where word2vec model should be saved vector_size : int Number of dimensions of vector window : int Number of words considered as context min_count : int Number of occurrences a word should have to be considered in training n_jobs : int Number of cpu cores used for calculation method : str Method to use in model training . Options cbow and skip - gram default : skip - gram ) Returns ------- word2vec . Word2Vec
def train_word2vec_model(infile_name, outfile_name=None, vector_size=100, window=10, min_count=3, n_jobs=1,
                         method='skip-gram', **kwargs):
    """Trains word2vec (Mol2vec, ProtVec) model on corpus file extracted from molecule/protein sequences.
    The corpus file is treated as LineSentence corpus (one sentence = one line, words separated by whitespaces)
    
    Parameters
    ----------
    infile_name : str
        Corpus file, e.g. proteins split in n-grams or compound identifier
    outfile_name : str
        Name of output file where word2vec model should be saved
    vector_size : int
        Number of dimensions of vector
    window : int
        Number of words considered as context
    min_count : int
        Number of occurrences a word should have to be considered in training
    n_jobs : int
        Number of cpu cores used for calculation
    method : str
        Method to use in model training. Options cbow and skip-gram, default: skip-gram)
    
    Returns
    -------
    word2vec.Word2Vec
    """
    if method.lower() == 'skip-gram':
        sg = 1
    elif method.lower() == 'cbow':
        sg = 0
    else:
        raise ValueError('skip-gram or cbow are only valid options')
  
    start = timeit.default_timer()
    corpus = word2vec.LineSentence(infile_name)
    model = word2vec.Word2Vec(corpus, size=vector_size, window=window, min_count=min_count, workers=n_jobs, sg=sg,
                              **kwargs)
    if outfile_name:
        model.save(outfile_name)
    
    stop = timeit.default_timer()
    print('Runtime: ', round((stop - start)/60, 2), ' minutes')
    return model
def train_word2vec_model ( infile_name , outfile_name = None , vector_size = 100 , window = 10 , min_count = 3 , n_jobs = 1 , method = 'skip-gram' , * * kwargs ) : if method . lower ( ) == 'skip-gram' : sg = 1 elif method . lower ( ) == 'cbow' : sg = 0 else : raise ValueError ( 'skip-gram or cbow are only valid options' ) start = timeit . default_timer ( ) corpus = word2vec . LineSentence ( infile_name ) model = word2vec . Word2Vec ( corpus , size = vector_size , window = window , min_count = min_count , workers = n_jobs , sg = sg , * * kwargs ) if outfile_name : model . save ( outfile_name ) stop = timeit . default_timer ( ) print ( 'Runtime: ' , round ( ( stop - start ) / 60 , 2 ) , ' minutes' ) return model