HyperProjection舞“排球少年!!顶端的风景”幕后纪录剧情简介

") # 2. 训练词向量 all_words = data.get_all_words() # 用所有的数据集来训练词向量,而不是只用训练集。 w2v = Word2Vec([all_words], sg=1, size=vector_size, negative=5, iter=5, window=5) vector = [] for w in all_words: vector.append(w2v.wv[w]) # 3. 将无子集的电影删除。删除后同步更新全部的all_movies、all_words、all_movies_to_clean print("电影大集合的数量", len(all_movies)) all_movies = data.remove_no_subset(all_movies) print("删除子集后的电影大集合的数量", len(all_movies)) for i in range(len(all_movies)): if not all_words[i] in all_movies: all_movies = None all_words = None all_movies_to_clean = None vector = None break # 4. 将影评中的影评词语转化成词向量 review_words = pd.read_csv("stage3Datasets/" predictionId ".csv") review_words = review_words["review_words"].values review_vectors = [] for w in review_words: try: print(w) review_vectors.append(w2v.wv[w]) except: continue # 5. 计算影评中的单词平均向量,即唯一向量 review_sum = 0 for v in review_vectors: review_sum = v review_vector = review_sum/len(review_vectors) # 6. 将所有影片通过平均向量的相似度进行排序 sim = [] for v in vector: sim.append(cosine_similarity(review_vector.reshape(-1, 1), v.reshape(-1, 1))) sim = np.array(sim) print("#"*80) print(sim) print(type(sim)) print("#"*80) print(sim.shape) sim = sim.reshape(-1, 1) target_index = np.argsort(sim, axis=0)[::-1]

猜你喜欢

再见,福宝

2024/韩国/纪录片,传记

6号小姐:音乐把我拯救

2013/加拿大/美国/英国/剧情,纪录片,短片,音乐,传记

大国崛起

2006/大陆/纪录片

环法自行车赛:逆风飞驰

2023/法国/英国/纪录片,运动