2018-06-01から1ヶ月間の記事一覧

f表記がPython3.6から使える

item1 = 'apple' item2 = 'bananas' item3 = 'grapes' print('At the grocery store, I bought some {0} and {1} and {2}.'.format(item1,item2,item3)) print('At the grocery store, I bought some {0} and {1} and {2}.'.format('apple',2,3))#intも入れ…

shelve したあと、中身みたいとき。

# 変数専用ファイルにデータを保管 pickle モジュールを使う import shelve shelve_file = shelve.open('friend') my_friend = ['A_san', 'B_san', 'C_san'] shelve_file['my_friend'] = my_friend print(shelve_file.keys) a =list(map(str,shelve_file)) p…

jupyter_notebookでのモジュールを自動で読み込み直すやつ

%reload_ext autoreload %autoreload 2

mapがわからなくなるのでメモ

a = list(range(1,100)) print(list(map(str, a)))

たまにsplitとjoinがわからなくなるのでメモ(ついでにmap)

a = '1 2 3 4 5 6 7 8' b = list(a.split()) print(b) ['1', '2', '3', '4', '5', '6', '7', '8'] c= ",".join(b) print(type(c)) <class 'str'> d = list(map(int,b)) print(d) [1, 2, 3, 4, 5, 6, 7, 8]</class>

pwdとcdをpython os モジュールで やってみる。

import os #カレントディレクトリ os.getcwd() #ディレクトリ移動(一つ上のディレクトリへ) os.chdir('../')

train_test_splitでtrain_sizeを指定しないとどんな割合でテストデータ作るのか?

train_sizeを指定しないと、75%25%みたい。 from sklearn.model_selection import train_test_split as split # 学習用データ,テスト用データ,学習用の正解ラベル, テスト用の正解ラベル = train_test_split(データ, データ正解ラベル,train_size=学習用デー…

train_test_split の書き方

from sklearn.model_selection import train_test_split as split x_train, x_test, y_train, y_test = split(iris.data,iris.target, train_size=0.85, test_size=0.15) 学習用データ,テスト用データ,学習用の正解ラベル, テスト用の正解ラベル = train_tes…

KitematicからのOffical MySQLのパスワードを設定

Kitematicから「General」から「Envorionment Variables」に KEYにMYSQL_ROOT_PASSWORD VALUEに設定したパスワードを入れる。