Python、データサイエンス、および選択:パート4

ポスト#4のための 初心者は、データの可視化技術について。





視覚化の重要性

前に示したような単純な視覚化手法により、大量の情報を簡潔に伝えることができます。これらは、この一連の投稿で以前に計算した要約統計量を補完するものであるため、それらを使用できることが非常に重要です。平均や標準偏差などの統計は、シーケンスを1つの数値にまとめるため、必然的に多くの情報を隠します。





イギリスの数学者フランシス・アンスコムは、現在アンスコムのカルテットとして知られている、ほぼ同一の統計的特性(平均、分散、標準偏差など)を持つ4つのドットプロットのコレクションを編集しましたこれにもかかわらず、それらはシーケンスの値の分布が非常に発散していることを明確に示しています:





, . , 2013 .:





, — 30% — . , — - .





, , , . , , , . 30% , . , 5% .





, 1938 ., . , 50 : , 1, .





, , , , , , . , , , .





, , . sp.random.normal



scipy, . 0 1, , . 70150 7679.





. :





def ex_1_24():
    '''     
        '''
    emp      = load_uk_scrubbed()['Electorate']
    fitted   = stats.norm.rvs(emp.mean(), emp.std(ddof=0), len(emp))
    df  = empirical_cdf(emp)
    df2 = empirical_cdf(fitted)
    ax  = df.plot(0, 1, label='')    
    df2.plot(0, 1, label='', grid=True, ax=ax)    
    plt.xlabel('')
    plt.ylabel('')
    plt.legend(loc='best')
    plt.show()
      
      



:





, . , .





, , :





def ex_1_25():
    '''   
        '''
    qqplot( load_uk_scrubbed()['Electorate'] )
    plt.show()
      
      



, :





, . , , , .





, , , . Victors () , (Con) - (LD) , .





def ex_1_26():
    '''    ""  
            '''
    df = load_uk_scrubbed()
    df[''] = df['Con'] + df['LD']
    freq = Counter(df['Con'].apply( lambda x: x > 0 ))
    print(' "": %d,  ..  %d' 
          % (freq[True], freq[False]))
      
      



 "": 631,  ..  19
      
      



, 19 . , - : Con LD ( ), , ? Counter, :





'''    
   " " (Con)  
   "- " (LD)'''
df = load_uk_scrubbed()
Counter(df['Con'].apply(lambda x: x > 0)), 
    Counter(df['LD'].apply(lambda x: x > 0))
      
      



(Counter({False: 19, True: 631}), Counter({False: 19, True: 631}))
      
      



, , . isnull



, , , :





def ex_1_27():
    '''    ,  
       " " (Con)  
       "-" (LD)  '''
    df   = load_uk_scrubbed()
    rule = df['Con'].isnull() & df['LD'].isnull()
    return df[rule][['Region', 'Electorate', 'Con', 'LD']]
      
      



 





Region





Electorate





Con





LD





12





Northern Ireland





60204.0





NaN





NaN





13





Northern Ireland





73338.0





NaN





NaN





14





Northern Ireland





63054.0





NaN





NaN

























584





Northern Ireland





64594.0





NaN





NaN





585





Northern Ireland





74732.0





NaN





NaN





, . , . , ? . , - , - , . , , , — — , .





, , , , . , , :





def load_uk_victors():
    '''   , 
          '''
    df = load_uk_scrubbed()
    rule = df['Con'].notnull()
    df   = df[rule][['Con', 'LD', 'Votes', 'Electorate']] 
    df['']       = df['Con']        + df['LD'] 
    df[' '] = df[''] / df['Votes'] 
    df['']             = df['Votes']      / df['Electorate']
    return df
      
      



: Victors, Victors Share Turnout, .. , . , , :





def ex_1_28():
    '''    
          '''
    qqplot( load_uk_victors()[' '] )
    plt.show()
      
      



:





, , , , , « » . , , , .





Github. .





, 5, «Python, » .








All Articles