작성
·
44
0
소스코드:
movies_df['genres_literal'] = movies_df['genres'].apply(lambda x : (' ').join(x))
count_vect = CountVectorizer(min_df=0, ngram_range=(1,2))
genre_mat = count_vect.fit_transform(movies_df['genres_literal'])
print(genre_mat.shape)
에러 코드:
InvalidParameterError Traceback (most recent call last)
Cell In[99], line 10
8 count_vect = CountVectorizer(min_df=0, ngram_range=(1,2))
9 # print(movies_df['genres_literal'])
---> 10 genre_mat = count_vect.fit_transform(movies_df['genres_literal'])
File D:\dev03\anaconda\Lib\site-packages\sklearn\base.py:1467, in _fit_context.<locals>.decorator.<locals>.wrapper(estimator, *args, **kwargs)
1462 partial_fit_and_fitted = (
1463 fit_method.__name__ == "partial_fit" and _is_fitted(estimator)
1464 )
1466 if not global_skip_validation and not partial_fit_and_fitted:
-> 1467 estimator._validate_params()
1469 with config_context(
1470 skip_parameter_validation=(
1471 prefer_skip_nested_validation or global_skip_validation
1472 )
1473 ):
1474 return fit_method(estimator, *args, **kwargs)
File D:\dev03\anaconda\Lib\site-packages\sklearn\base.py:666, in BaseEstimator._validate_params(self)
658 def _validate_params(self):
659 """Validate types and values of constructor parameters
660
661 The expected type and values must be defined in the `_parameter_constraints`
(...)
664 accepted constraints.
665 """
--> 666 validate_parameter_constraints(
667 self._parameter_constraints,
668 self.get_params(deep=False),
669 caller_name=self.__class__.__name__,
670 )
File D:\dev03\anaconda\Lib\site-packages\sklearn\utils\_param_validation.py:95, in validate_parameter_constraints(parameter_constraints, params, caller_name)
89 else:
90 constraints_str = (
91 f"{', '.join([str(c) for c in constraints[:-1]])} or"
92 f" {constraints[-1]}"
93 )
---> 95 raise InvalidParameterError(
96 f"The {param_name!r} parameter of {caller_name} must be"
97 f" {constraints_str}. Got {param_val!r} instead."
98 )
InvalidParameterError: The 'min_df' parameter of CountVectorizer must be a float in the range [0.0, 1.0] or an int in the range [1, inf). Got 0 instea
답변 1
0
안녕하십니까,
설치하신 사이킷런 버전이 실습 버전과 안 맞아서 그런것 같습니다. CountVectorizer가 업그레이드 된것 같습니다.
min_df=0.0 으로 해보시지요.
감사합니다.
감사합니다.
사이킷런 1.0.2 파이썬 3.9.18로 다운그레이하니
정상작동되었습니다.