Rのデータフレーム操作用パッケージ
Pythonでいうpandasのようなものという認識
参考リンク
dplyr入門 (新版)
dplyrを使いこなす!基礎編 - Qiita
Rのデータフレーム操作用パッケージ
Pythonでいうpandasのようなものという認識
参考リンク
dplyr入門 (新版)
dplyrを使いこなす!基礎編 - Qiita
リスク比、オッズ比などを計算するためのRのパッケージ
riskratio: Calculate risk ratio and its confidence intervals in fmsb: Functions for Medical Statistics Book with some Demographic Data
RやPythonで使える可視化ツール
3Dのグラフを書くのに便利
Rパッケージ
public
日時データの処理に特化したパッケージ
tidyverseに含まれる
Make Dealing with Dates a Little Easier • lubridate
Rパッケージ
R
Rでグラフをプロットするためのパッケージ
Rパッケージ
public
Jupyterそのものを動かすconda envと、カーネルのconda envを分けて管理する
こうするとブラウザやVSCodeから接続するJupyterは一つだけで良く、他のenvではカーネルだけインストールすればよい形になる
新しくconda envを作ったときには以下のコマンドでJupyterカーネルを追加する必要がある
# target envを有効化
source activate ~/work/conda/graphtool/
RでExcelファイルを読み込む
readxlパッケージのread_excel()を使う
Use read_xls() and read_xlsx() directly if you know better and want to prevent such guessing.
library(readxl)
df = read_excel(
【統計ソフトR】カラム名をつけた0行のdata.frameを作成したい | FOR-REST
n <- 3
df <- data.frame(matrix(rep(NA, n), nrow=1))[numeric(0), ]
colnames(df) <- c("column1", "column2", "column3")
quiet <- function(x) {
sink(tempfile())
on.exit(sink())
invisible(force(x))
}
総乗、つまり∏を綺麗に実装したい
英語だとproduct of sequenceというらしい
総乗関数
計算用の関数を別に定義しておく
関数の引数は
library(lubridate)
get_first_day_of_month = function(date) {
return(lubridate::floor_date(date, unit = "month"))
}
get_last_day_of_month = function(date) {
Rのリスト/配列は二種類ある
厳密にはvectorという
foo = c(): generic vector
bar = vector(): atomic vector
計算結果を配列のように追加していきたいときはこっちの方が良い
データフレームのindex(Rではrowname)を消す
# df = data.frame(foo=c(1,2,3,4,5)*3, bar=c(2,3,4,5,6)*5, row.names=c(1,2,3,4,5))
rownames(df) = NULL
R
public
Rで複数(3つ以上)のデータフレームを結合する
Reduce(
function(...) merge(..., by='SomeColumnName', type="inner"),
list(df1, df2, df3)
)
Rで、Pythonでいうfor i in range(N)をする
for (i in 0:N) {
print(i)
}
参考
ggplotでいい感じのサイズでファイルを出力する
DeLuciatoRライブラリを使う
もともとのfigureに縦横比に合わせて、max widthとmax heightの範囲内にfitしてくれる
PDFもそれ以外もOK
library("DeLuciatoR")
options(repos="https://ftp.yz.yamagata-u.ac.jp/pub/cran/")
@IlI_lIl_lIl_lIl:
東京のCRANミラーサイトがダウンしてるっぽい
ミラー一覧
https://cran.r-project.org/mirrors.html
実行時間を測る
Julia
@time for n = 1:N-1
y[n+1] = (1-h)y[n]
end
eggパッケージを使う
library("egg")
# fig1a = ggplot()
# fig1b = ggplot()
fig1 = ggarrange(fig1a, fig1b, nrow=1)
Rで日付列のデータ型を指定していい感じにCSVを読み込む
df_case = read_csv(
"data/newly_confirmed_cases_daily.csv",
col_types = cols(Date = col_date(format = "%Y/%m/%d"))
)
ggplotで縦横比を指定する
プロットエリアだけ
凡例などを含めない、座標系だけの縦横比
+
coord_fixed()
# 縦線
geom_vline(xintercept=as.Date("2021-12-01"), linetype='dotted', color='red') +
# 横線
geom_vline(yintercept=100, linetype='dotted', color='red') +
[http://www.sthda.com/english/wiki/ggplot2-add-straight-lines-to-a-plot-horizontal-vertical-and-regression-lines ggplot2 add straight lines to a plot : horizontal, vertical and regression lines - Easy
ggplotでPDFを出力する
ggsaveでcairo_pdfを指定する
ggsave("figure/image.pdf", device=cairo_pdf)
R
20211115
やりたいこと
リモートサーバにSSHして作業しているときに、そのディレクトリをローカルマシン(Mac)のVS Codeで開きたい
利用シーンの例
Claude Codeでgit worktreeを使って作業→成果物をローカルで開いてレビューしたい
ssh <my-mac-hostname> "/opt/homebrew/bin/code --remote ssh-remote+<remote-hostname> $(pwd)"
Bell number
n 人を区別のない k 個以下のグループに分ける方法の数
https://ja.wikipedia.org/wiki/ベル数
組み合わせ
public
# vim myservice.service
systemctl link myservice.service # symlink
sudo systemctl daemon-reload
sudo systemctl start myservice.service
sudo systemctl status myservice.service
message passing neural networks
基本的には値をpassする
distributionをpassするアプローチもある
分布そのものではなくモーメントをpassする
message passing
LinuxでHDDを初期化する
2TB以上の場合はgdiskを使ってGPT(GUID Partition Table) を設定するのがポイント
https://debimate.jp/2019/10/05/gdisk-mkfsコマンドで2tb以上のhddをフォーマットする方法/
ディスクを確認する
lsblk -f
Multilayer Perceptron
多層パーセプトロン
hidden layerが一つであるMLPは、任意の連続関数を任意の精度で近似できる = 普遍性定理 (Universal Approximation theorem)
The universal approximation theorem means that regardless of what functionwe are trying to learn, we know that a large MLP will be able to represent thisfunction.
Graph kernels can be intuitively understood as functions measuring the similarity of pairs of graphs.
https://en.wikipedia.org/wiki/Graph_kernel
https://ethz.ch/content/dam/ethz/special-interest/bsse/borgwardt-lab/documents/slides/CA10_GraphKernels_intro.pdf
Ubuntu 24.04+LightDMのシステムをサーバとして使っているときに勝手にsuspendしてしまう現象
LightDMはリモートデスクトップのみで使用されることを想定していないらしい
リモートデスクトップ/SSHのみで使用している場合、"inactive"として認識して30分後にsuspendをトリガーする
https://askubuntu.com/questions/1337649/how-to-disable-suspend-in-20-minutes-from-the-lightdm-login-screen
sudo mkdir -p /etc/polkit-1/localauthority/50-local.d/
sudo vim /etc/polkit-1/localauthority/50-local.d/45-allow-xrdp.pkla
[Allow Colord for xrdp users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profi
ラプラシアンの第2固有値
拡散速度や情報の伝播効率を表す
λ2が大きいほど
拡散が速く進む
ネットワーク全体が速く平衡に達する
temperature=0 のとき: greedy algorithm
最適化
public
人材データを分析して、組織の課題解決につなげる取り組み
HR
人事
public
チーム編成 = memberとtaskのマッピングと最適化
hypergraphを使って表現し、最適化できる
/minami-bookmarks/2403.04063 Assigning Entities to Teams as a Hypergraph Discovery Problem
Team Formation Problem
hypergraph
Home Assistant OSをIncusで動かす
https://mforcen.dev/en/wabl/home-assistant-over-incus
# mkdir -p ~/vm/home-assistant/
# cd ~/vm/home-assistant/
# Check latest version from https://github.com/home-assistant/operating-system/releases/
Incusをインストールする
https://linuxcontainers.org/incus/docs/main/installing/#installing
インストール方法が2つある
Native incus package
Zabbly package repository
モデラーは説明性を重視する
複雑な(説明性が低い)モデルを使うのであれば、その説明性のトレードオフに値するだけの圧倒的な精度向上が必要という立場
c.f. Occam's razor
コンピュータサイエンティストは予測精度を重視する
複雑であっても予測精度が上がればよい
Scrapboxを含め任意の場所に公開したp5.jsスクリプトを実行してHTMLとして描画するCloudflare Workersをつくった
ベースは以下を参考にさせてもらった
/testspace/Scrapboxで書いたp5jsのコードブロックを実行する
https://github.com/masakick/runp5/tree/gh-pages
変更点
近傍(neighborhood)という考え方は最適化アルゴリズムやグラフ学習で広く用いられる
最適化アルゴリズム
cooperative optimizationという考え方がある
具体的なアルゴリズムとしてはParticle Swarm Optimizationなど
粒子群が探索空間を飛び回って目的関数を最小化する
Graph Attention Network
public