あるのかなー?ってググったらあった。すごい。
Data Sampling In Prestoragrawal.wordpress.com
FROM dataset TABLESAMPLE BERNOULLI(25)
テーブル名のあとに↑のように指定すると25%のデータがランダムサンプリングされて取得できる
あるのかなー?ってググったらあった。すごい。
Data Sampling In Prestoragrawal.wordpress.com
FROM dataset TABLESAMPLE BERNOULLI(25)
テーブル名のあとに↑のように指定すると25%のデータがランダムサンプリングされて取得できる
全然理解していなかった。上を参考に後日追加する。
まだ遊べていないのでログ残し
自分はpull
で対応
$ docker pull postgresql:10.5
で、run
しようとすると
$ docker run --rm --name=postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -it postgres psql -U postgres psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
なんやねんこれ?
/bin/bash
してみて、それで起動してみる.
$ docker run --rm --name=postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -it postgres /bin/bash root@badb9c06d26c:/# root@badb9c06d26c:/# ps aux | grep postgres
どうやら起動してない模様
root@badb9c06d26c:/# service postgresql start [warn] No PostgreSQL clusters exist; see "man pg_createcluster" ... (warning).
なるほど? ぐぐる
Ran following commands, and after that Postgres was running.
root@ee38e70bca23:/# dpkg-reconfigure locales root@ee38e70bca23:/# pg_createcluster 9.5 main --start root@ee38e70bca23:/# /etc/init.d/postgresql start
なるほど。手順通りたたく(バージョンは調整した
すると起動した!が、しかし、ログインに失敗する。
眠たいので続きは明日.
続き
上の原因はrootログインで失敗していたので
su - postgres
でpostgresユーザーに変更psql -U postgres
でログイン、パスワード変更postgres_hba.conf
をmd5
, trust
に変更する。本番ではtrust
は良くないメンドクサ!!!!ってなったのでimages削除して下記を対応したらできた。
つらい
volume作らないとコンテナ削除したとき一緒にデータが消えてしまうので、volumeを作る
DB作成とかテーブル作成はguiのclientアプリを使ったら簡単
以上、これでできた
RuntimeError: No mappable was found to use for colorbar creation. First define a mappable such as an image (with imshow) or a contour set (with contourf).
X_reduced = TSNE(n_components=2, random_state=0).fit_transform(X) _, ax = plt.subplots(figsize=(12, 9)) ax.scatter(X_reduced[:, 0], X_reduced[:, 1], c=data['label']) plt.colorbar()
t-sneで次元削減したデータをscatterでplotしようとしたらエラーがでた。
ぐぐると、下記で解決したがいまいちよくわかっていない
X_reduced = TSNE(n_components=2, random_state=0).fit_transform(X) _, ax = plt.subplots(figsize=(12, 9)) ax.scatter(X_reduced[:, 0], X_reduced[:, 1], c=data['label']) pcm = ax.get_children()[0] plt.colorbar(pcm, ax=ax)
ax.get_children()
[<matplotlib.collections.PathCollection at 0x7f41e2b26fd0>, <matplotlib.spines.Spine at 0x7f41e25c4cf8>, <matplotlib.spines.Spine at 0x7f41e25c4ba8>, <matplotlib.spines.Spine at 0x7f41e25c49b0>, <matplotlib.spines.Spine at 0x7f41e25c4940>, <matplotlib.axis.XAxis at 0x7f41e25c44a8>, <matplotlib.axis.YAxis at 0x7f41e261f160>, Text(0.5,1,''), Text(0,1,''), Text(1,1,''), <matplotlib.patches.Rectangle at 0x7f41e28d3470>]
ax.get_children()
をみてみると、こんな感じ↑でオブジェクトがあるので、0番目のオブジェクトを渡すとうまくいった。ということを覚えておく(理解はしていない