작성
·
44
0
안녕하세요. 교수님 너무 좋은 강의 잘 듣고 있습니다.
바쁘실텐데 바로바로 답변해주셔서 너무 감사드려요^^
Bike Sharing Demend 예제소스 에러 질문이 있어서요..
최근에 설치했는데.. 에러가 많이나서
사이킷런 1.0.2 파이썬 3.9.18으로 다운그레이했습니다. 넘파이는 몇버전으로 해야 할까요?
아래는 에러내용입니다.
[ 로그 변환, 피처 인코딩, 모델 학습/예측/평가 ]
from sklearn.model_selection import train_test_split , GridSearchCV
from sklearn.linear_model import LinearRegression , Ridge , Lasso
y_target = bike_df['count']
X_features = bike_df.drop(['count'],axis=1,inplace=False)
X_train, X_test, y_train, y_test = train_test_split(X_features, y_target, test_size=0.3, random_state=0)
lr_reg = LinearRegression()
lr_reg.fit(X_train, y_train)
pred = lr_reg.predict(X_test)
evaluate_regr(y_test ,pred)
에러
---------------------------------------------------------------------------
DTypePromotionError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_19124\3974685920.py in <module>
11 lr_reg = LinearRegression()
12
---> 13 lr_reg.fit(X_train, y_train)
14 pred = lr_reg.predict(X_test)
15
D:\dev03\anaconda\lib\site-packages\sklearn\linear_model\_base.py in fit(self, X, y, sample_weight)
660 accept_sparse = False if self.positive else ["csr", "csc", "coo"]
661
--> 662 X, y = self._validate_data(
663 X, y, accept_sparse=accept_sparse, y_numeric=True, multi_output=True
664 )
D:\dev03\anaconda\lib\site-packages\sklearn\base.py in _validate_data(self, X, y, reset, validate_separately, **check_params)
579 y = check_array(y, **check_y_params)
580 else:
--> 581 X, y = check_X_y(X, y, **check_params)
582 out = X, y
583
D:\dev03\anaconda\lib\site-packages\sklearn\utils\validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, estimator)
962 raise ValueError("y cannot be None")
963
--> 964 X = check_array(
965 X,
966 accept_sparse=accept_sparse,
D:\dev03\anaconda\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
663
664 if all(isinstance(dtype, np.dtype) for dtype in dtypes_orig):
--> 665 dtype_orig = np.result_type(*dtypes_orig)
666
667 if dtype_numeric:
DTypePromotionError: The DType <class 'numpy.dtypes.