25년 실기 연습문제 풀이(6번) 에러 발생

아래 코드와 에러에 대해 설명부탁합니다.

1) 코딩

y_pred_test=model.predict(test)
from sklearn.preprocessing import MinMaxScaler
#수치형 컬럼만 선택
numeric_cols = ['tenure','TotalCharges']

2) 에러

--------------------------------------------------------------------------- ValueError                                Traceback (most recent call last) Cell In[23], line 1 ----> 1 y_pred_test=model.predict(test)      2 from sklearn.preprocessing import MinMaxScaler      3 #수치형 컬럼만 선택 File ~\anaconda3\Lib\site-packages\sklearn\ensemble\_forest.py:981, in ForestRegressor.predict(self, X)    979 check_is_fitted(self)    980 # Check data --> 981 X = self._validate_X_predict(X)    983 # Assign chunk of trees to jobs    984 n_jobs, _, _ = _partition_estimators(self.n_estimators, self.n_jobs) File ~\anaconda3\Lib\site-packages\sklearn\ensemble\_forest.py:602, in BaseForest._validate_X_predict(self, X)    599 """    600 Validate X whenever one tries to predict, apply, predict_proba."""    601 check_is_fitted(self) --> 602 X = self._validate_data(X, dtype=DTYPE, accept_sparse="csr", reset=False)    603 if issparse(X) and (X.indices.dtype != np.intc or X.indptr.dtype != np.intc):    604     raise ValueError("No support for np.int64 index based sparse matrices") File ~\anaconda3\Lib\site-packages\sklearn\base.py:548, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params)    483 def _validate_data(    484     self,    485     X="no_validation",   (...)    489     **check_params,    490 ):    491     """Validate input data and set or check the `n_features_in_` attribute.    492    493     Parameters   (...)    546         validated.    547     """ --> 548     self._check_feature_names(X, reset=reset)    550     if y is None and self._get_tags()["requires_y"]:    551         raise ValueError(    552             f"This {self.__class__.__name__} estimator "    553             "requires y to be passed, but the target y is None."    554         ) File ~\anaconda3\Lib\site-packages\sklearn\base.py:481, in BaseEstimator._check_feature_names(self, X, reset)    476 if not missing_names and not unexpected_names:    477     message += (    478         "Feature names must be in the same order as they were in fit.\n"    479     ) --> 481 raise ValueError(message) ValueError: The feature names should match those that were passed during fit. Feature names unseen at fit time: - TotalCharges - customerID

 

 


 

0

댓글

댓글 1개
날짜 투표수
  • 안녕하세요 

    25년 도서의 정오표 확인 요청 드립니다.

    구글에서 AI EDU 검색하시고 자료실에 빅분기 파트에서 25년 빅데이터 분석기사 실기 R 작업형

    파일이 있습니다.  확인 요청 드립니다.!

    0

댓글을 남기려면 로그인하세요.

 

원하는 것을 찾지 못하셨나요?

질문하기