タグ

numpyに関するU1and0のブックマーク (12)

  • Python pandas パフォーマンス維持のための 3 つの TIPS - StatsFragments


    pandas  Cython  Numba 使 Enhancing Performance  pandas 0.16.2 documentation   Cython Numba 使pandas  pandas pandas /  
    Python pandas パフォーマンス維持のための 3 つの TIPS - StatsFragments
    U1and0
    U1and0 2018/07/27
    行に対するループ / DataFrame.apply は 使わない object 型は使わない ユニークでない / ソートされていない index は使わない
  • NumPy でビンの作成、データとビンの対応関係の取得 - Qiita

    データをビンに分けてヒストグラム等を描画する処理自体は、matplotlibの hist() に array を渡せばデータに応じて良い感じのビンに切り分けて描画してくれますが、任意のビンでデータを分けたい場合や、どのデータがどのビンに入っているか知りたい場合があります。 今回は、ビンの作成および、データとビンの対応関係を取得を行います。 分布の作成 まず適当な分布の array を作成します。

    NumPy でビンの作成、データとビンの対応関係の取得 - Qiita
    U1and0
    U1and0 2018/06/02
    np.digitizeとは histgram, binsとの関係
  • 【NumPy】回帰分析で直線近似(線形フィッティング)

    直線近似(回帰分析) PythonモジュールNumPyでは、polyfitメソッドで回帰分析ができます。 書式 a, b = numpy.polyfit(x, y, 1) ■返り値 a:近似直線の傾き b:近似直線の切片 ソースコード サンプルプログラムのソースコードです。 # -*- coding: utf-8 import numpy as np import matplotlib.pyplot as plt def main(): # CSVのロード data = np.genfromtxt("nikkei16.csv",delimiter=",", skip_header=1, dtype='float') # 5行目を抽出(日経平均株価の終値) f = data[:,4]/1000.0 # xの値を生成 x = np.linspace(1, len(f), len(f)) # フ

    【NumPy】回帰分析で直線近似(線形フィッティング)
    U1and0
    U1and0 2018/05/10
    線形フィッティングだったら`from scipy.optimize import curve_fit`しないでも`np.polyfit()`で事足りる
  • matplotlibで3Dグラフを描画する - white wheelsのメモ


     numpypyplot3mpl_toolkits.mplot3d from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np 3(2)2 arangex,y1 x = np.arange(-3, 3, 0.25) y = np.arange(-3, 3, 0.25) 2meshgridX,YXxYy X, Y =
    matplotlibで3Dグラフを描画する - white wheelsのメモ
    U1and0
    U1and0 2017/01/15
    “Z = np.sin(X)+ np.cos(Y) fig = plt.figure() ax = Axes3D(fig) ax.plot_wireframe(X,Y,Z) #<---ここでplot”
  • Best way to initialize and fill an numpy array?

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives

    Best way to initialize and fill an numpy array?
    U1and0
    U1and0 2016/12/05
    a = np.empty(3) * np.nan shareimprove this answer edited Mar 14 '14 at 20:45 answered Mar 14 '14 at 19:45 shx2 28.9k54679 Thanks for modify in place hint. That is what was confusing me. – tbc Mar 14 '14 at 20:32 add a comment up vote 23 down vote You could also try: In [79]: np.full(3, np.nan) Out
  • pandasのプロット機能を使いJupyter上で作図 - Qiita


     OS X El Capitan 10.11.6 python: 2.7.11 pandas: 0.18.0 matplotlib: 1.5.1 numpy: 1.10.4 IPython: 4.1.2  Python10Pythonmatplotlib使seabornBokehggplotR使 pandasmatplotlib使
    pandasのプロット機能を使いJupyter上で作図 - Qiita
  • NumPy 配列の基礎 — 機械学習の Python との出会い

    NumPy 配列の基礎¶ ここでは,NumPy で最も重要なクラスである np.ndarray について, チュートリアルの方針 の方針に従い,最低限必要な予備知識について説明します. np.ndarray は, N-d Array すなわち,N次元配列を扱うためのクラスです. NumPy を使わない場合, Python ではこうしたN次元配列を表現するには,多重のリストが利用されます. np.ndarray と多重リストには以下のような違いがあります. 多重リストはリンクでセルを結合した形式でメモリ上に保持されますが, np.ndarray は C や Fortran の配列と同様にメモリの連続領域上に保持されます. そのため,多重リストは動的に変更可能ですが, np.ndarray の形状変更には全体の削除・再生成が必要になります. 多重リストはリスト内でその要素の型が異なることが許

  • Numpyによる乱数生成まとめ - Qiita

    Python標準にも random というモジュールがあるが、ベクトル演算の可能な numpy のほうが「大量に乱数を生成してなんかの処理をする」という場合に高速に動く。あと分布関数が山ほど用意されている。 一様乱数 numpy.random.rand() で 0〜1 の一様乱数を生成する。引数を指定すれば複数の乱数を生成できる。乱数の範囲を変えたい場合は後からベクトル演算をすれば良い。 from numpy.random import * rand() # 0〜1の乱数を1個生成 rand(100) # 0〜1の乱数を100個生成 rand(10,10) # 0〜1の乱数で 10x10 の行列を生成 rand(100) * 40 + 30 # 30〜70の乱数を100個生成 from numpy.random import * """ 標準正規分布。いわゆるガウシアン。標準正規分布ならば

    Numpyによる乱数生成まとめ - Qiita
    U1and0
    U1and0 2016/08/21
    from numpy.random import * rand() # 0〜1の乱数を1個生成 rand(100) # 0〜1の乱数を100個生成 rand(10,10) # 0〜1の乱数で 10x10 の行列を生成
  • Pythonの数値計算ライブラリ NumPy入門


    Scientific Computing Tools For Python  Numpy NumPy  Python(via Wikipedia) NumPyNumPySciPyOpenCV()NumPyPython OpenCVPython * VPSOpenCVPython使 [2017/04/2
  • iPython Notebookの--pylab inlineは使うのをやめようという話 - Wolfeyes Bioinformatics beta


    TL;DR ipython notebook --pylab inlineipython notebook --matplotlib inline使ipython%matplotlib inlineiPython Notebook iPython便PythoniPython NotebookmatplotlibRRstudio+knitr (http://nbviewer.ipython.org/gist/twiecki/3962843)
    U1and0
    U1and0 2016/07/29
    ipython notebook --matplotlib inlineで起動する %matplotlib inlineをiPython Notebookの冒頭で実行しておく どっちか
  • Fancy Indexing:配列の一部を条件をつけて取り出す - おっぱいそん!

    aを適当なN次元配列とする。 a[a_1, a_2, a_3, ]とすると、配列の1つの成分を取り出せる。 a[リスト]とすると、1次元配列のリスト番目の成分のみ取り出した配列を返す。 (上の用に配列の1つの成分だけ取り出したい時にはtuple(リスト)のようにtupleにして渡せば良い) a[リスト1,リスト2,リスト3, ]とすると、1次元目をリスト1で2次元目をリスト2で、といったように取り出した配列を返す。 np.ix_をつかってa[np.ix_([行],[列])]とすると行列の一部の行と列のみ取り出した新しい行列を作れる。 ※ここまでのリストは配列にしても同じ。 同じことをbool値を使って、a[[行のbool],[列のbool],[3次元目のbool], ]とも出来る(これはリストにすると、False=0, True=1と解釈されるので注意)。 import numpy as

    Fancy Indexing:配列の一部を条件をつけて取り出す - おっぱいそん!
  • Random sampling (numpy.random) — NumPy v1.15 Manual

    Return a sample (or samples) from the “standard normal” distribution.

    U1and0
    U1and0 2016/04/29
    ランダム関数まとめ
  • 1