No 날짜 기업 코드 기업명 업종 시가총액 EV EPS(원) BPS(원) PER \ 0 1 2024-06-01 10130 고려아연 비철금속 106622…
- User
No 날짜 기업 코드 기업명 업종 시가총액 EV EPS(원) BPS(원) PER
0 1 2024-06-01 10130 고려아연 비철금속 106622 99452 8498.0 462760 60.4
1 2 2024-03-01 10130 고려아연 비철금속 94507 82083 5109.0 453563 88.5
2 3 2023-12-01 10130 고려아연 비철금속 104125 92652 9078.0 451351 54.9
3 4 2023-09-01 10130 고려아연 비철금속 100508 89242 3839.0 448038 130.4
4 5 2023-06-01 10130 고려아연 비철금속 96833 92750 6068.0 453263 80.3... 순이익(지배) 영업현금 부채비율 버핏의 주주이익 당기순이익 감가상각비(유형무형) CAPEX(유형+무형)
0 ... 1767.0 5792.0 0.365 NaN 1755.0 915.0 6362.0
1 ... 1068.0 2519.0 0.240 NaN 1124.0 836.0 907.0
2 ... 1898.0 2729.0 0.249 NaN 1930.0 811.0 1418.0
3 ... 771.0 5729.0 0.250 NaN 778.0 787.0 989.0
4 ... 1205.0 -1402.0 0.233 NaN 1242.0 770.0 996.0주당배당금(원) 종업원수(명) 1인당 급여액(천원)
0 10000.0 1881.0 -52053.0
1 0.0 NaN NaN
2 5000.0 1878.0 37956.0
3 0.0 1873.0 21720.0
4 10000.0 1830.0 20617.0이런 형식으로 여러 기업이 있어
- Assistant
이 데이터세트는 여러 기업의 재무 및 운영 관련 정보를 시간순으로 정리한 것 같습니다. 데이터는 기업 코드, 기업명, 업종, 시가총액 등 다양한 재무 지표와 함께 제공됩니다. 주요 컬럼은 다음과 같습니다:
- 날짜: 데이터 수집 혹은 계산된 날짜
- 기업 코드: 기업 식별을 위한 고유 코드
- 기업명: 기업의 이름
- 업종: 기업이 속한 산업 분야
- 시가총액: 기업의 시장 가치
- EV: 기업 가치 (Enterprise Value)
- EPS(원): 주당 순이익
- BPS(원): 주당 순자산
- PER: 주가수익비율
- 순이익(지배) 및 당기순이익: 일정 기간 동안 기업의 순이익
- 영업현금: 영업활동현금흐름
- 부채비율: 총 부채 비율
- 감가상각비(유형무형): 유형 및 무형 자산에 대한 감가상각비
- CAPEX(유형+무형): 자본적 지출
- 주당배당금(원): 주당 지급되는 배당금
- 종업원수(명): 기업의 직원 수
- 1인당 급여액(천원): 직원 1인당 평균 급여
이 데이터세트를 활용하여 기업의 재무적 건강 상태를 분석하거나, 투자 결정을 내리는 데 사용할 수 있을 것 같습니다. 각 지표는 특정 기간 동안 기업의 성과를 평가하는 데 중요한 역할을 하며, 시계열 분석을 통해 기업의 성장 패턴이나 추세를 파악하는 데 유용합니다. 만약 특정한 분석이나 시각화가 필요하다면, 구체적인 방법을 제안해 드릴 수 있습니다.
- User
각 기업에 대해 다중회귀 분석을 수행하여 2024년 6월의 EV(기업가치)를 예측하고, 그 결과를 바탕으로 모델 성능을 평가하는 머신러닝 코드를 제공해
- Assistant
다중회귀 분석을 통해 각 기업에 대해 특정 시점의 EV(기업가치)를 예측하는 작업은 비교적 간단합니다. Python의
pandas,sklearn,numpy라이브러리를 사용하면 이런 작업을 효율적으로 수행할 수 있습니다. 아래는 예제 코드로, 각 기업에 대해 학습을 수행하고 2024년 6월의 EV를 예측하는 프로세스를 보여줍니다.import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error, r2_score import numpy as np # 데이터 파일을 로드합니다. 또, 필요한 형식으로 써주세요. # df = pd.read_csv('data.csv') # 데이터를 CSV로부터 로드하는 경우 # 예제 데이터를 DataFrame으로 구성한다고 가정 data = { '날짜': ['2024-06-01', '2024-03-01', '2023-12-01', '2023-09-01', '2023-06-01'], '기업 코드': [10130, 10130, 10130, 10130, 10130], '기업명': ['고려아연', '고려아연', '고려아연', '고려아연', '고려아연'], 'EV': [99452, 82083, 92652, 89242, 92750], 'EPS(원)': [8498.0, 5109.0, 9078.0, 3839.0, 6068.0], 'PER': [60.4, 88.5, 54.9, 130.4, 80.3], '순이익(지배)': [1767.0, 1068.0, 1898.0, 771.0, 1205.0], '당기순이익': [1755.0, 1124.0, 1930.0, 778.0, 1242.0], # 필요한 다른 변수들도 포함 } df = pd.DataFrame(data) # 것은 기업 코드나 기업명을 제거한 뒤, X, y로 나눕니다. X = df[['EPS(원)', 'PER', '순이익(지배)', '당기순이익']] # 다른 특성들을 포함할 수 있음 y = df['EV'] # 교육용 데이터와 테스트 데이터를 나눕니다. X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # 모델 초기화 및 학습 model = LinearRegression() model.fit(X_train, y_train) # 예측 y_pred = model.predict(X_test) # 모델 성능 평가 mse = mean_squared_error(y_test, y_pred) r2 = r2_score(y_test, y_pred) print(f'Mean Squared Error: {mse:.2f}') print(f'R^2 Score: {r2:.2f}') # 2024년 6월 데이터로 EV 예측 df_future = pd.DataFrame({ 'EPS(원)': [8498.0], # 실제 미래 데이터를 여기에 추가하세요 'PER': [60.4], # 실제 미래 데이터를 여기에 추가하세요 '순이익(지배)': [1767.0], # 실제 미래 데이터를 여기에 추가하세요 '당기순이익': [1755.0] # 실제 미래 데이터를 여기에 추가하세요 }) future_ev_pred = model.predict(df_future) print(f'Predicted EV for 2024-06-01: {future_ev_pred[0]:.2f}')설명:
-
데이터 준비: 데이터를 DataFrame으로 준비합니다. 여기에는 'EV'와 관련된 여러 변수들이 포함되어야 합니다.
-
특성 및 타겟 분리: 모델 학습을 위해 종속 변수와 독립 변수를 나눕니다.
-
데이터 분할: 데이터셋을 학습과 테스트 데이터로 나눠모델의 성능을 평가할 때 데이터가 어떻게 일반화되는지 확인합니다.
-
모델 학습:
LinearRegression클래스를 사용하여 다중회귀 모델을 학습합니다. -
모델 평가: 테스트 데이터를 통해 모델의 성능을 평가합니다. 여기서는 평균 제곱 오차(MSE)와 결정 계수(R^2)를 사용합니다.
-
미래 데이터로 예측: '2024년 6월'의 데이터를 사용하여 EV를 예측합니다.
주어진 코드에서는 예제 데이터를 사용했습니다. 실제 데이터로 대체해야 하며, 모든 가능성을 고려해 모델을 튜닝할 수도 있습니다.
-
- User
기업이 고려아연 뿐만 아니라 700개가 넘게 있어
- Assistant
700개 이상의 기업에 대해 다중회귀 분석을 수행하여 각 기업의 EV를 예측하려면, 각 기업마다 모델을 개별적으로 학습시키는 방법도 있고, 전체 데이터를 결합하여 하나의 모델을 사용하는 방법도 있습니다. 두 번째 방법은 데이터가 너무 크지 않다면 데이터 구조상 더 효율적일 수 있습니다.
여기서는 각 기업에 대해 개별적으로 다중회귀 모델을 학습시키고, EV를 예측하는 방법을 예제 코드로 제공합니다. 이 방법은 기업별로 모델을 만들어 성능 상의 이점이 있을 때 유용합니다.
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error, r2_score import numpy as np # 여기에 실제 데이터 파일을 로드합니다. # df = pd.read_csv('your_data.csv') # 데이터는 CSV 파일로부터 로드합니다. # 임시 데이터 생성 (자신의 데이터로 대체해야 함) data = { '날짜': [...], # 각 기업의 날짜 정보 '기업 코드': [...], # 기업 코드 '기업명': [...], # 기업명 'EV': [...], # 기업가치 'EPS(원)': [...], # ... 'PER': [...], '순이익(지배)': [...], '당기순이익': [...], # 필드 추가 } df = pd.DataFrame(data) # 결과 저장용 results = [] # 기업별로 그룹화해서 개별 모델 생성 및 예측 수행 for company_code, group in df.groupby('기업 코드'): try: # X, y 설정 X = group[['EPS(원)', 'PER', '순이익(지배)', '당기순이익']] y = group['EV'] # 데이터 분할 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # 모델 학습 model = LinearRegression() model.fit(X_train, y_train) # 예측 y_pred = model.predict(X_test) # 평가 mse = mean_squared_error(y_test, y_pred) r2 = r2_score(y_test, y_pred) # 2024년 6월 데이터 생성 (예제) future_data = X.iloc[-1:] # 새로운 데이터나 마지막 행 등을 사용하는 예 future_ev_pred = model.predict(future_data)[0] # 결과 저장 results.append({ '기업 코드': company_code, '기업명': group['기업명'].iloc[0], 'MSE': mse, 'R^2': r2, 'Predicted EV for 2024-06-01': future_ev_pred }) except Exception as e: print(f"Error processing company code {company_code}: {e}") # 결과 DataFrame으로 정리 results_df = pd.DataFrame(results) # 필요에 따라 CSV로 저장할 수 있습니다. # results_df.to_csv('company_ev_predictions.csv', index=False) # 결과 출력 print(results_df)설명:
-
데이터 그룹화:
groupby('기업 코드')를 사용하여 각 기업별로 데이터를 그룹화합니다. -
모델 학습 및 예측: 그룹화된 각 데이터셋에 대해 다중회귀 모델을 학습시키고, 테스트 데이터를 통해 모델 성능을 평가합니다.
-
예측 수행: 각 기업의 가장 최신 데이터를 사용하여 2024년 6월 EV를 예측합니다. 예제에서는
X의 마지막 행을 사용했지만, 실제로는 해당 시점의 데이터를 제공해야 합니다. -
결과 저장: 각 기업의 예측 결과 및 모델 성능을 목록으로 저장합니다.
이 코드는 모든 기업에 대해 개별적으로 회귀 분석을 수행하고 예측하는 데 사용할 수 있습니다. 실제 사용자 데이터에 맞는 컬럼명과 특징 선택을 해야 하므로, 실제 데이터에 맞춰 수정이 필요할 수도 있습니다.
-
- User
Error processing company code 220: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 370: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 760: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 810: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 970: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1200: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1270: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1290: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1450: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1500: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1510: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 1720: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 2630: Input X contains NaN. ... Error processing company code 3610: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 3690: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings... /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) Error processing company code 5090: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 5390: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 5500: With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters. Error processing company code 5800: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 5830: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 5940: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 5960: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 6220: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 6800: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 6880: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 8060: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 8110: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 8870: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values ... Error processing company code 11300: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 12170: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings... /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) Error processing company code 16360: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 16610: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 16740: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 21820: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 23350: With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters. Error processing company code 24110: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 24720: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 26890: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 27410: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 29780: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 30210: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 30610: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 32830: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values ... Error processing company code 143210: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 155660: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings... /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) Error processing company code 161890: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 175330: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 192400: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 214320: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 214330: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 214420: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 241560: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 251270: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 272210: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 286940: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 293940: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 308170: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Error processing company code 316140: Input X contains NaN. ... Error processing company code 443060: With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters. Error processing company code 446070: With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters. Error processing company code 950210: Input X contains NaN. LinearRegression does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-values Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings... /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sklearn/metrics/_regression.py:1211: UndefinedMetricWarning: R^2 score is not well-defined with less than two samples. warnings.warn(msg, UndefinedMetricWarning)
- Assistant
주어진 오류 메시지는 데이터셋에
NaN값이 포함되어 있어LinearRegression모델이 학습할 수 없다는 것을 나타냅니다. 이 문제를 해결하기 위해서는 데이터 전처리가 필요합니다. 특히,NaN값을 처리할 때 몇 가지 접근 방법이 있습니다:NaN값 제거: 데이터셋에서NaN값을 포함하는 행을 제거합니다.- Imputation (대체):
NaN값을 다른 값으로 대체합니다. 예를 들어, 열의 평균, 중앙값, 최빈값 등으로 대체할 수 있습니다.
아래는
SimpleImputer를 사용하여NaN값을 평균값으로 대체하는 방법을 포함한 수정된 코드입니다:import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error, r2_score from sklearn.impute import SimpleImputer import numpy as np # 여기에 실제 데이터 파일을 로드합니다. # df = pd.read_csv('your_data.csv') # 데이터는 CSV 파일로부터 로드합니다. # 임시 데이터 생성 (자신의 데이터로 대체해야 함) data = { '날짜': [...], # 각 기업의 날짜 정보 '기업 코드': [...], # 기업 코드 '기업명': [...], # 기업명 'EV': [...], # 기업가치 'EPS(원)': [...], # ... 'PER': [...], '순이익(지배)': [...], '당기순이익': [...], # 필드 추가 } df = pd.DataFrame(data) # 결과 저장용 results = [] # 기업별로 그룹화해서 개별 모델 생성 및 예측 수행 for company_code, group in df.groupby('기업 코드'): try: # X, y 설정 X = group[['EPS(원)', 'PER', '순이익(지배)', '당기순이익']] y = group['EV'] # Drop rows with NaNs in target variable group = group.dropna(subset=['EV']) # Impute missing values using the mean of each column imputer = SimpleImputer(strategy='mean') X_imputed = imputer.fit_transform(X) # 데이터 분할 X_train, X_test, y_train, y_test = train_test_split(X_imputed, y, test_size=0.2, random_state=42) # 모델 학습 model = LinearRegression() model.fit(X_train, y_train) # 예측 y_pred = model.predict(X_test) # 평가 mse = mean_squared_error(y_test, y_pred) r2 = r2_score(y_test, y_pred) # 2024년 6월 데이터 생성 (예제) future_data = X.iloc[-1:].values.reshape(1, -1) # 새로운 데이터나 특성들을 불러옴 future_data_imputed = imputer.transform(future_data) future_ev_pred = model.predict(future_data_imputed)[0] # 결과 저장 results.append({ '기업 코드': company_code, '기업명': group['기업명'].iloc[0], 'MSE': mse, 'R^2': r2, 'Predicted EV for 2024-06-01': future_ev_pred }) except Exception as e: print(f"Error processing company code {company_code}: {e}") # 결과 DataFrame으로 정리 results_df = pd.DataFrame(results) # 필요에 따라 CSV로 저장할 수 있습니다. # results_df.to_csv('company_ev_predictions.csv', index=False) # 결과 출력 print(results_df)주요 변경 사항:
-
SimpleImputer사용:SimpleImputer를 사용하여NaN값을 평균으로 대체합니다. 이는 모든 특성에서 결측치가 있을 때 유용한 방법입니다. -
NaN값 제거: 목표 변수인EV에NaN이 있는 행들은 제거합니다. 이는 회귀 모델을 학습하기 위해 필수적입니다. -
reshape사용:future_data에서reshape를 통해 모델 입력 형식에 맞춥니다.
이 방법은 데이터 전처리를 통해
NaN문제를 해결하므로, 각 기업별 회귀 분석을 성공적으로 수행할 수 있습니다. 필요에 따라 다른 imputation 방법이나 데이터 전처리 기술을 적용할 수 있습니다.