簡體   English   中英

為什么TPOT推薦分類器的得分低於LinearSVC?

[英]Why does the score of TPOT recommend classifier is lower than LinearSVC?

所以我發現LinearSVC在TPOT分類器中並且我一直在將它用於我的模型並得到相當不錯的分數(sklearn分數為0.95)。

def process(stock):
  df = format_data(stock)
  df[['HSI Volume', 'HSI', stock]] = df[['HSI Volume', 'HSI', stock]].pct_change()

# shift future value to current date
  df[stock+'_future'] = df[stock].shift(-1)
  df.replace([-np.inf, np.inf], np.nan, inplace=True)
  df.dropna(inplace=True)
  df['class'] = list(map(create_labels, df[stock], df[stock+'_future']))
  X = np.array(df.drop(['class', stock+'_future'], 1)) # 1 = column
  # X = preprocessing.scale(X)
  y = np.array(df['class'])

  X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.2)

  tpot = TPOTClassifier(generations = 10, verbosity=2)
  fitting = tpot.fit(X_train, y_train)
  prediction = tpot.score(X_test, y_test)
  tpot.export('pipeline.py')
  return fitting, prediction

十代后:TPOT推薦GaussianNB,在sklearn評分中得分約為0.77。

Generation 1 - Current best internal CV score: 0.5322255571                     
Generation 2 - Current best internal CV score: 0.55453535828                    
Generation 3 - Current best internal CV score: 0.55453535828                    
Generation 4 - Current best internal CV score: 0.55453535828                    
Generation 5 - Current best internal CV score: 0.587469903893                   
Generation 6 - Current best internal CV score: 0.587469903893                   
Generation 7 - Current best internal CV score: 0.597194474469                   
Generation 8 - Current best internal CV score: 0.597194474469                   
Generation 9 - Current best internal CV score: 0.597194474469                   
Generation 10 - Current best internal CV score: 0.597194474469                  

Best pipeline: GaussianNB(RBFSampler(input_matrix, 0.22))
(None, 0.54637855142056824)

我很好奇為什么LinearSVC得分較高但TPOT不推薦。 是因為評分機制不同而導致了不同的最優分類器?

非常感謝!

我的個人猜測是tpot卡在局部最大值上,可能會嘗試改變測試大小,做更多代或縮放數據可能會有所幫助。 此外,你能重做TPOT,看看你是否得到相同的結果? (我的猜測是否定的,因為遺傳優化因突變而不確定)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM