728x90
반응형
문제
Prophet에서 회귀변수를 추가하기 위해 add_regressor('name') 함수를 사용했더니 'Regressor 'name' missing from dataframe'에러가 나왔다.
해결
이를 해결하기 위해서는 future_dataframe에도 동일한 이름의 column이 존재해야 한다.
future = m.make_future_dataframe(periods=365)
future['name'] = df['name']
위의 코드와 같이 df와 future 모두 name(회귀하고싶은 변수 명)이 동일하게 있어야 해당 문제를 해결할 수 있다.
혹시 Found NaN in column 'name' 오류를 발견하게 된다면 다음 글을 확인해보자!
2023.01.18 - [분류 전체보기] - [Prophet] Found NaN in column 'name' 에러
[Prophet] Found NaN in column 'name' 에러
문제 add_regressor('name')함수를 사용하고 forecast = m.predict(future)를 했더니 위와 같은 에러가 나왔다. 해결 이는 회귀변수의 미래 값이 없기 때문이다. future.fillna(method='ffill',inplace=True) 없는 값을 fillna
joinmycode.tistory.com
예시 코드
from prophet import Prophet
import pandas as pd
df = pd.read_csv('EX.csv') # ds, y, reg 가 있다고 가정
m = Prophet()
m.add_regressor('reg')
future = m.make_future_dataframe(periods=365)
future['reg'] = data1['reg']
m.fit(data1)
forecast = m.predict(future)
728x90
반응형
'# Time Series > # Prophet' 카테고리의 다른 글
[Prophet] TypeError: ufunc 'isfinite' not supported for the input types 에러 (0) | 2023.01.20 |
---|---|
[Prophet] Found NaN in column 'name' 에러 (0) | 2023.01.18 |
[Time Series] Neural Prophet 정리 (0) | 2023.01.18 |
[Time Series] Prophet 정리 (0) | 2023.01.18 |