国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

分類模型——變量選擇

CloudDeveloper / 1521人閱讀

摘要:系數(shù)反映每個特征的影響力。越大表示該特征在分類中起到的作用越大

import numpy as np  
import scipy as sp  
import pandas as pd
import matplotlib.pyplot as plt
Split train and test
from sklearn.cross_validation import train_test_split
x_train, x_test, y_train, y_test = train_test_split(customer.ix[:,0:customer.columns.size-1], customer.ix[:,customer.columns.size-1], test_size = 0.2)
x_train, x_test, y_train, y_test = train_test_split(order.ix[:,0:order.columns.size-1], order.ix[:,order.columns.size-1], test_size = 0.2)
Pearson Correlation for Order
from scipy.stats import pearsonr  

prr = []
for i in range(order.columns.size-1):
   frame = pearsonr(order.iloc[:,i], order.iloc[:,order.columns.size-1]) 
   prr.append(frame)

result = pd.concat([pd.DataFrame(order.columns.values.tolist()), pd.DataFrame(prr)], axis=1) 
result.columns = ["Features", "Pearson", "Pvalue"]
result
result.to_csv("result.csv", index = True, header = True)
Pearson Correlation for Customer
from scipy.stats import pearsonr  
prr = []
for i in range(customer.columns.size-1):
   frame = pearsonr(customer.iloc[:,i], customer.iloc[:,customer.columns.size-1]) 
   prr.append(frame)

result = pd.concat([pd.DataFrame(customer.columns.values.tolist()), pd.DataFrame(prr)], axis=1) 
result.columns = ["Features", "Pearson", "Pvalue"]
result
result.to_csv("result.csv", index = True, header = True)
Random forest
from sklearn.ensemble import RandomForestRegressor  
clf = RandomForestRegressor()
clf.fit(x_train, y_train)

from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(n_jobs=100)
clf.fit(x_train, y_train)
MIC
from minepy import MINE
mic = []
for i in range(customer.columns.size-1):
   frame = m.compute_score(customer.iloc[:,i], customer.iloc[:,34]) 
   prr.append(frame)
result = pd.concat([pd.DataFrame(customer.columns.values.tolist()), pd.DataFrame(prr)], axis=1) 
result.columns = ["Features", "Pearson", "Pvalue"]
result.to_csv("result.csv", index = True, header = True)
Feature Correlation
corr = customer.corr()
corr.to_csv("result.csv", index = True, header = True)

tar_corr = lambda x: x.corr(x["tar"])
cus_call.apply(tar_corr)
cus_call.corrwith(cus_call.tar)
Feature Importance

系數(shù)反映每個特征的影響力。越大表示該特征在分類中起到的作用越大

importances = pd.DataFrame(sorted(zip(x_train.columns, map(lambda x: round(x, 4), clf.feature_importances_)), reverse=True))
importances.columns = ["Features", "Importance"]
importances.to_csv("result.csv", index = True, header = True)

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/44567.html

相關(guān)文章

  • 隨機森林算法入門(python)

    摘要:翻譯自昨天收到推送了一篇介紹隨機森林算法的郵件,感覺作為介紹和入門不錯,就順手把它翻譯一下。隨機森林引入的隨機森林算法將自動創(chuàng)建隨機決策樹群。回歸隨機森林也可以用于回歸問題。結(jié)語隨機森林相當(dāng)起來非常容易。 翻譯自:http://blog.yhat.com/posts/python-random-forest.html 昨天收到y(tǒng)hat推送了一篇介紹隨機森林算法的郵件,感覺作為介紹和入門...

    張遷 評論0 收藏0
  • 機器學(xué)習(xí)算法基礎(chǔ)(使用Python代碼)

    摘要:機器學(xué)習(xí)算法類型從廣義上講,有種類型的機器學(xué)習(xí)算法。強化學(xué)習(xí)的例子馬爾可夫決策過程常用機器學(xué)習(xí)算法列表以下是常用機器學(xué)習(xí)算法的列表。我提供了對各種機器學(xué)習(xí)算法的高級理解以及運行它們的代碼。決策樹是一種監(jiān)督學(xué)習(xí)算法,主要用于分類問題。 showImg(https://segmentfault.com/img/remote/1460000019086462); 介紹 谷歌的自動駕駛汽車和機...

    BenCHou 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<