2016-12-23 18 views
0

현재 변수와 관측치가있는 데이터 세트가 있습니다. 나는 하나의 변수 인 (수요)를 예측하고 싶다. 그래서 나는 회귀 모델을 사용할 필요가있다. Linear Regression으로 시도한 결과, R2 측정 항목 (약 0.85)을 사용하여 평가했습니다. 다른 모델과의 성능을 평가하고 싶었는데 그 중 하나는 NNs이었습니다. 나는 신경망이 분류와 같은 다른 업무에 더 적합하다고 믿지만, 그럼에도 불구하고 나는 그것들을 시험해보고 싶었다. 이 두 모델 (선형 회귀 분석 및 다중 계층 퍼셉트론)를 제공 주로하기 때문에 MLPRegressor를 조정하는 방법은 무엇입니까?

내가 scikit-learn를 사용하기로 결정, 물건은 R2 메트릭이 선형 회귀의 일에 비해 너무 멀리 나쁜 것입니다. 따라서 나는 많은 중요한 구성이 빠져 있다는 결론을 내렸다. 아래에서 내 코드와 데이터가 어떻게 나타나는지 확인할 수 있습니다.

내 데이터는 다음과 같은 열이 만 demand (내 레이블 인), population, gdp, dayyear 연속 수치이다 있고, 나머지는 범주입니다.

['demand','holy','gdp','population', 'day','year', 'f0', 'f1', 'f2', 'f3', 'f4','f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f20', 'f21', 'f22', 'f23', 'g0', 'g1', 'g2', 'g3', 'g4', 'g5', 'g6', 'g7', 'g8', 'g9', 'g10', 'g11'] 

이것은 내가 실제로하는 일이며, 일부 출력물을 제거했습니다.

import pandas as pd 
import numpy as np 
import math as math 

from sklearn.linear_model import LinearRegression 
from sklearn.neural_network import MLPRegressor 
from sklearn.metrics import r2_score 



training_data, validation_data = np.split(data.sample(frac=1), [int(.8*len(data))]) 

linear_model = LinearRegression().fit(training_data[[c for c in data.columns if c != "demand"]], training_data[["demand"]]) 

validation_data_predictions = linear_model.predict(validation_data[[c for c in training_data.columns if c != "demand"]]) 

validation_predictions_pd = pd.DataFrame(data=validation_data_predictions, 
             index=validation_data.index.values, 
             columns=["prediction"]) 

# join both pandas 
result_df = validation_data.join(validation_predictions_pd, how="inner") 

r2_error = r2_score(y_true=result_df[["demand"]], y_pred=result_df[["prediction"]], multioutput="uniform_average") 

print(r2_error) # outputs 0.85 


# NN section 
clf = MLPRegressor(hidden_layer_sizes=(10,), max_iter=100000) 

neural_model = clf.fit(training_data[[c for c in training_data.columns if c != "demand"]], training_data[["demand"]]) 

validation_data_predictions = neural_model.predict(validation_data[[c for c in training_data.columns if c != "demand"]]) 

validation_predictions_pd = pd.DataFrame(data=validation_data_predictions, 
            index=validation_data.index.values, 
            columns=["prediction"]) 

result_df = validation_data.join(validation_predictions_pd, how="inner") 

r2_error = r2_score(y_true=result_df[["demand"]], y_pred=result_df[["prediction"]], multioutput="uniform_average") 
print(r2_error) # outputs 0.23 

NN의 성능은 매우 낮습니다. 그리고 그 성능은 향상 될 수 있다고 생각합니다. 어떤 힌트일까요?

+0

알베르토, 당신은 확인하십시오 수 당신의 예제가 재현 가능합니까? 'data' 변수를 정의하여 다른 사람들이 가시적 인 도움을 줄 수 있도록하십시오. 건배! –

답변

0

아마 NN의 성능이 좋지 않을 수도 있습니다. 어쩌면 당신은 단지 그들을 비교하기 위해 잘못된 측정 항목을 사용하고있을 수도 있습니다. 일반적으로 많은 회귀 변수가있는 선형 회귀 모델을 평가할 때 R2 점수를 신뢰하는 것은 좋지 않습니다. 실제로 모델에 더 많은 회귀 변수를 사용하면 R 제곱 값이 높아집니다 (see this video for a quick explanation).

어쨌든 나는이 질문 https://stats.stackexchange.com/

1
  1. MLP는 기능 확장에 민감 더 적합하다고 생각합니다. 데이터를 정상화 시켰습니까?

  2. 네트워크 구조를 수정 : 더 숨겨진 레이어와 각 레이어 SIGMOD/TANH/relu에

  3. 변경 활성화 기능의 퍼셉트론 즈 (Perceptrons)의 변경 번호를 추가하는 등

관련 문제