Understanding min_df and max_df in scikit CountVectorizer

前端 未结 5 1619
生来不讨喜
生来不讨喜 2020-12-04 06:41

I have five text files that I input to a CountVectorizer. When specifying min_df and max_df to the CountVectorizer instance what does the min/max document frequency exactly

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 07:12

    max_df is used for removing terms that appear too frequently, also known as "corpus-specific stop words". For example:

    • max_df = 0.50 means "ignore terms that appear in more than 50% of the documents".
    • max_df = 25 means "ignore terms that appear in more than 25 documents".

    The default max_df is 1.0, which means "ignore terms that appear in more than 100% of the documents". Thus, the default setting does not ignore any terms.


    min_df is used for removing terms that appear too infrequently. For example:

    • min_df = 0.01 means "ignore terms that appear in less than 1% of the documents".
    • min_df = 5 means "ignore terms that appear in less than 5 documents".

    The default min_df is 1, which means "ignore terms that appear in less than 1 document". Thus, the default setting does not ignore any terms.

提交回复
热议问题