Python 3.x 使用TF-IDF或Word2Vec从工作描述中提取技能

Python 3.x 使用TF-IDF或Word2Vec从工作描述中提取技能,python-3.x,machine-learning,word2vec,pos-tagger,tfidfvectorizer,Python 3.x,Machine Learning,Word2vec,Pos Tagger,Tfidfvectorizer,我有一种情况,我需要从可用的工作描述中提取申请工作的特定申请人的技能,并将其存储为一个新列。 dataframe X如下所示: Job_ID Job_Desc 1 Applicant should posses technical capabilities including proficient knowledge of python and SQL 2 Applicant should posses technical capa

我有一种情况,我需要从可用的工作描述中提取申请工作的特定申请人的技能,并将其存储为一个新列。 dataframe X如下所示:

Job_ID        Job_Desc 
1             Applicant should posses technical capabilities including proficient knowledge of python and SQL
2             Applicant should posses technical capabilities including proficient knowledge of python and SQL and R
Job_ID       Skills
1            Python,SQL
2            Python,SQL,R
结果输出应如下所示:

Job_ID        Job_Desc 
1             Applicant should posses technical capabilities including proficient knowledge of python and SQL
2             Applicant should posses technical capabilities including proficient knowledge of python and SQL and R
Job_ID       Skills
1            Python,SQL
2            Python,SQL,R
我已经使用tf idf count矢量器获取Job_Desc列中最重要的单词,但仍然无法在输出中获取所需的技能数据。通过Word2Vec使用skip gram或CBOW模型是否可以实现这一点

我的代码如下所示:

from sklearn.feature_extraction.text import CountVectorizer
cv=CountVectorizer(max_df=0.50)
word_count_vector=cv.fit_transform(X)

from sklearn.feature_extraction.text import TfidfTransformer
tfidf_transformer=TfidfTransformer(smooth_idf=True,use_idf=True)
tfidf_transformer.fit(word_count_vector)

def sort_coo(coo_matrix):
tuples = zip(coo_matrix.col, coo_matrix.data)
return sorted(tuples, key=lambda x: (x[1], x[0]), reverse=True)

def extract_topn_from_vector(feature_names, sorted_items, topn=10):
"""get the feature names and tf-idf score of top n items"""

#use only topn items from vector
sorted_items = sorted_items[:topn]

score_vals = []
feature_vals = []

for idx, score in sorted_items:
    fname = feature_names[idx]

    #keep track of feature name and its corresponding score
    score_vals.append(round(score, 3))
    feature_vals.append(feature_names[idx])

#create a tuples of feature,score
#results = zip(feature_vals,score_vals)
results= {}
for idx in range(len(feature_vals)):
    results[feature_vals[idx]]=score_vals[idx]

return results

feature_names=cv.get_feature_names()
doc=X[0]

tf_idf_vector=tfidf_transformer.transform(cv.transform([doc]))
sorted_items=sort_coo(tf_idf_vector.tocoo())
keywords=extract_topn_from_vector(feature_names,sorted_items,10)
print("\n=====Title=====")
print(X[0])
print("\n===Keywords===")
for k in keywords:
   print(k,keywords[k])

我想不出TF-IDF、Word2Vec或其他简单/无监督算法能够单独识别您需要的“技能”类型的方法

你可能需要一个庞大的手工编制的技能列表——至少,作为一种自动评估声称提取技能的方法的方法

有了精心策划的列表,Word2Vec之类的东西可能有助于建议同义词、替代形式或相关技能。(对于已知的技能X,以及文本中的大型Word2Vec模型,类似于X的术语可能是类似的技能-但不能保证,因此您可能仍然需要人工审查/管理。)

如果有一个足够大的数据集将文本映射到结果,例如,将候选人描述文本(简历)映射到人的评论员是否选择他们进行面试、是否雇用他们,或者他们是否成功地完成了一项工作,那么您可能能够识别出能够高度预测是否适合某个工作角色的术语。这些术语通常可能是事实上的“技能”。但是发现这些相关性可能是一个更大的学习项目。

这里有一个建议,建议采用与您建议的方法类似的方法

它建议结合使用LSTM+单词嵌入(无论它们来自word2vec、BERT等) 由于TF-IDF计算重要性的方式,您可能不会获得很好的结果。这些技能很可能只被提及一次,而且帖子也很短,所以使用的许多其他单词也很可能只被提及一次


正如本文所建议的,您可能需要创建一个培训数据集,该数据集包含来自职位公告的文本,标签为skill或not skill。

您也可以尝试使用名称实体识别!