<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          數(shù)據(jù)處理過程

          共 1902字,需瀏覽 4分鐘

           ·

          2020-08-30 22:53

          一般步驟

          • 定義所要解決的問題,針對該問題得到一些基礎(chǔ)的想法

          • 查閱與問題相關(guān)的文獻,找到適合解決問題的幾種方法

          • 然后改進這些方法以適合自己的要求

          了解數(shù)據(jù)

          • 理解問題:查看數(shù)據(jù)的每一個變量,并對其進行簡單分析,把認為最重要的幾個挑出來

          • 單因素分析:關(guān)注因變量,并對其深入分析

          • 多因素研究:分析因變量與自變量之間的關(guān)系

          • 數(shù)據(jù)清洗:處缺失數(shù)據(jù)和異常值

          • 檢驗假設(shè):檢查數(shù)據(jù)是否和多元分析方法的假設(shè)達到一致

          準備工作

          • 變量:變量的名字

          • 變量類型:數(shù)值或者類別

          • 劃分:按種類劃分變量

          • 期望:我們所期望變量所達到的對自變量的影響程度

          • 結(jié)論:對該變量得出的重要結(jié)論,最好與期望一致

          Python數(shù)據(jù)描述與處理

          因變量數(shù)據(jù)描述

          #繪制直方圖
          sns.distplot(df['Dependent?variable']);

          #數(shù)據(jù)偏度和峰度
          print("Skewness:?%f"%df['Dependent?variable'].skew())
          print("Kurtosis:?%f"%df['Dependent?variable'].kurt())

          相關(guān)性變量分析

          #因變量與數(shù)值型變量關(guān)系
          #繪制散點圖,查看與變量的關(guān)系
          df.plot.scatter(x=var,y=depvar)

          #因變量與類別型變量關(guān)系
          #繪制箱線圖,查看趨勢
          sns.boxplot(x=?,y=?,data=?)

          #相關(guān)系數(shù)矩陣
          corrmat?=?df.corr()
          #熱圖
          sns.heatmap(corrmat)

          #因變量以及相關(guān)變量彼此之間的散點圖
          sns.set()
          cols=[var......]
          sns.pairplot(df[cols])
          plt.show()

          缺失數(shù)據(jù)處理

          缺失數(shù)據(jù)是否具有普遍性??
          缺失數(shù)據(jù)是否有律可循??
          我們需要保證缺失數(shù)據(jù)的處理不會出現(xiàn)偏離或者隱藏任何難以忽視的真相

          #將每個變量的缺失占比排序
          total?=?df.isnull().sum().sort_values(ascending=False)
          percent?=?(df.isnull().sum()/df.isnull.count).sort_values(ascending=False)
          missing_data?=?pd.concat([tol,percent],axis=1,keys=['Total','Percent'])
          print(missing_data.head(number))
          #當有15%的數(shù)據(jù)缺失時,應(yīng)該刪除改變量,并認為該變量應(yīng)該不存在

          單因素分析

          單因素分析的關(guān)鍵是建立閾值,定義一個觀察者為異常值。我們對數(shù)據(jù)進行正態(tài)化,均值為0,方差為1。

          scaled?=?StandardScaler().fit_transform(df['Dependent?variable'][:,np.newaxis]#標準化
          low_range?=?scaled[scaled[:,0].argsort()[:k]#取前k個
          high_range?=?scaled[scaled[:,0].argsort()[-k:]#取后k個

          雙變量分析

          畫出散點圖,查看離群值,刪除它

          data.plot.scatter(x=var,?y='dependent?variable');

          應(yīng)用多元技術(shù)

          • 正態(tài)性

          • 同方差性

          • 線性

          • 相關(guān)錯誤缺失

          1.正態(tài)性:

          #直方圖——峰值和偏度
          #正態(tài)概率圖——數(shù)據(jù)分布應(yīng)緊密跟隨正態(tài)分布對角線
          sns.distplot(df['dependent?variable'],fit=norm)
          res?=?stats.probplot(df['dependent?variable'],plot=plt)

          #可用對數(shù)變化解決不不跟隨正太分布對角線的問題
          df['dependent?variable']?=?np.log(df['dependent?variable'])

          2.同方差性:

          #繪制散點圖查看
          plt.scatter(df_train['var'],df_train['dependent?variable']);

          3.虛擬變量

          #將類別型變量轉(zhuǎn)化為虛擬變量
          df?=?pd.get_dummies(df)


          《數(shù)據(jù)科學(xué)與人工智能》公眾號推薦朋友們學(xué)習(xí)和使用Python語言,需要加入Python語言群的,請掃碼加我個人微信,備注【姓名-Python群】,我誠邀你入群,大家學(xué)習(xí)和分享。


          瀏覽 70
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  免费日本黄色网址 | 99热免费在线 | 无码高清操逼 | 丝袜足交一区二区三区 | 福利导航二三区 |