• Skip to main content
  • Skip to primary sidebar

学習記録

プログラミング

Jupyter notebookデバッグチートシート

2018年2月13日 by 河副 太智 Leave a Comment

 

以下のコードをデバッグしたいコードの上に書く
from IPython.core.debugger import Tracer; Tracer()()

例:

1
2
3
4
5
6
7
8
9
10
11
12
def test_debug(y):
    x = 10
    # One-liner to start the debugger here.
    from IPython.core.debugger import Tracer; Tracer()()
    x = x + y
    for i in range(10):
        x = x+i
    return x
test_debug(10)

 

実行するとコードの下にコマンド入力欄が出てくるので
変数を入れると変数の中身を表示してくれる。

その他デバッグコードはチートシートを参考にする

Jupyter notebookのデバッグのチートシート

Filed Under: Jupyter, チートシート

forを抜ける

2018年2月10日 by 河副 太智 Leave a Comment

breakで抜ける、passで何もしないで再度forに戻る

1
2
3
4
5
6
    for x in range((len(own_delated))):
        if own_delated[x] % 2 == 0:
            arr = np.append(arr, np.array([[1,own_delated[x]]]), axis=0)
            break
        else:
            pass

 

Filed Under: python3

データフレームに値を追加

2018年2月10日 by 河副 太智 Leave a Comment

numpyで2次元配列に行要素を追加していき、
最後にdataframeに変換

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import pandas as pd
import numpy as np
 
data = [[1,2],[3,4]]
data = np.append(data,[6, 4])
        
 
arr = np.empty((0,2), int)
arr = np.append(arr, np.array([[1,2]]), axis=0)
arr = np.append(arr, np.array([[3,4]]), axis=0)
print(arr)
 
 
data_frame = pd.DataFrame(arr, columns=['resolt', 'value'])
 
data_frame

 

Filed Under: Numpy, Pandas Tagged With: df, データフレーム, 要素, 追加, 配列

さくらvps

2018年2月5日 by 河副 太智 Leave a Comment

 

基本コマンド

i 編集モード
esc 編集モード終了
:q 保存せず終了
:q! 保存せず強制終了
:w 保存
:wq 保存して終了
/      検索
su –  ユーザー変更
yum list :インストールされているものを表示

 

インストールコード

vimのインストール  yum -y install vim-enhanced

Filed Under: vps

訓練済データを保存し、再利用する時短法

2018年1月31日 by 河副 太智 Leave a Comment

訓練済データを保存し、再利用

1
2
3
4
5
6
7
8
9
import pickle
 
#linerregression.pickleというファイルが生成される
with open('linerregression.pickle','wb') as f:
    pickle.dump(clf,f)
 
#訓練済みデータを呼び出す
pickle_in = open('linerregression.pickle','rb')
clf = pickle.load(pickle_in)

 

同じディレクトリ内であれば

1
2
pickle_in = open('linerregression.pickle','rb')
clf = pickle.load(pickle_in)

だけで訓練済みデータを呼びだせる

 

有料の深層学習用サーバーで学習させたデータを保存し、
再利用すれば経費削減にもつながる

Filed Under: 機械学習

scatter_matrix

2018年1月28日 by 河副 太智 Leave a Comment

スキャッターマトリクスと色づけ

1
2
grr = pd.scatter_matrix(iris_dataframe,c=y_train,figsize=(15,15),marker="o",
                       hist_kwds={"bins":20},s=60,alpha=.8,cmap=mglearn.cm3)

 

Filed Under: Pandas

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 13
  • Page 14
  • Page 15
  • Page 16
  • Page 17
  • Interim pages omitted …
  • Page 55
  • Go to Next Page »

Primary Sidebar

カテゴリー

  • AWS
  • Bootstrap
  • Dash
  • Django
  • flask
  • GIT(sourcetree)
  • Plotly/Dash
  • VPS
  • その他tool
  • ブログ
  • プログラミング
    • Bokeh
    • css
    • HoloViews
    • Jupyter
    • Numpy
    • Pandas
    • PosgreSQL
    • Python 基本
    • python3
      • webアプリ
    • python3解説
    • scikit-learn
    • scipy
    • vps
    • Wordpress
    • グラフ
    • コマンド
    • スクレイピング
    • チートシート
    • データクレンジング
    • ブロックチェーン
    • 作成実績
    • 時系列分析
    • 機械学習
      • 分析手法
      • 教師有り
    • 異常値検知
    • 自然言語処理
  • 一太郎
  • 数学
    • sympy
      • 対数関数(log)
      • 累乗根(n乗根)
    • 暗号学

Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in