python

グレブナー基底で連立多項式を解く、量子計算機でグレブナー基底を探す

https://arxiv.org/pdf/1903.08270.pdf pythonのsympyを使うとグレブナー基底が計算できる sagemath on pythonでもできる from sympy import * x,y,z = symbols('x y z') eqs =[x**2 + y**2 + z**2 - 4, x**2 + 2 * y**2 - 5, x*z-1] result = groebner(eqs,…

Let’s read the document "sklearn.tree.DecisionTreeClassifier"

scikit-learn.org Click the [https://github.com/scikit-learn/scikit-learn/blob/42aff4e2e/sklearn/tree/_classes.py#L607:title=\[source\]] and check that the information in the website is provided in the source. ソースコードを見てみよう The s…

Add library/package ライブラリ/パッケージの追加 pip, conda

Library > Package > Module Different terms... but, simply speaking, something you can get and use for your study. 名前が色々あるけれど、簡単に言えば、「取ってきて使うもの」 PyPI : Py-thon P-ackage I-ndex pypi.org python's libraries and pac…

Install Anaconda, Anacondaのインストール

Let's use Anaconda。Anacondaを使う www.anaconda.com Why? どうして? (1) It provides basic libraries/packages for data science (numpy, scipy, pandas). データサイエンス用の基本ライブラリ・パッケージが入っているから (numpy, scipy, pandas) num…

numpy.ndarray と Rのapply()

Rの行列で、各行の和を出そうと思ったら M <- matrix(rnorm(100),10,10) apply(M,1,sum) だろう 同じことをPythonでやるのはどうするのかな、と思った Pythonで行列を扱うならnumpyがよいのでそうすることにしたとして 値のセットの和を出すsum()関数を、軸…

RとPythonの両方で使えるplotlyでの3Dスキャタープロットを覚える

Rもpythonもjupyter notebookで文書作成できる 3次元プロットをしなくてよいのなら、Rでは普通の二次元プロッティング関数を使えばよいし、Pythonではmatplotlibを使えばよい 3次元プロットを描いてぐりぐり動かすとなると、Rではplot3dを使い、pythonでは…

Cross-Validation 実習

ノンパラメトリック・ベイズ実践編2 回帰

まず、単純に線形回帰 s <- rnorm(n,0,1) head(s) m <- matrix(s,ncol=2) head(m) lm_res <- lm(m[,2] ~ m[,1]) lm_res plot(m) abline(lm_res) pythonで行こう Scikit learn の gaussian process regression そのExamplesの一つ カーネル関数から、値のsimi…

ノンパラメトリック・ベイズ実践編

Non-parametric bayesian clustering Data set simulation n <- 1000 d <- 4 k <- 5 s <- sample(1:k,n,replace=TRUE) m <- matrix(rnorm(d*k,sd=6),k,d) X <- matrix(0,n,d) for(i in 1:k){ tmp <- which(s == i) r <- matrix(rnorm(d * length(tmp))) X[tm…

Maximum Mean DIscrepancy その3

Rのkernlab library(kernlab) # create data x <- matrix(runif(300),100) y <- matrix(runif(300)+1,100) mmdo <- kmmd(x, y) mmdo > mmdo Kernel Maximum Mean Discrepancy object of class "kmmd" Gaussian Radial Basis kernel function. Hyperparameter…

色覚異常フレンドリーなカラーパレット

色覚異常には先天性のものと後天性のものがあるが、先天性のものにも複数の種類が知られている。日本人に多いのは先天性赤緑色覚異常で、2種類に分かれます(こちら)。英語での名称はDichromacy (2種類がprotanopia and deuteranopia) 色覚異常がどういうこ…

ぱらぱらめくる『he Elements of Statistical Learning, Second Edition』

The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition (Springer Series in Statistics)作者: Trevor Hastie,Robert Tibshirani,Jerome Friedman出版社/メーカー: Springer発売日: 2008/12/01メディア: ハードカ…

python ⇔ c++

資料

4d data ROI(Region of interest)-analysis scipy.ndimageはarbitrary dimension arrayの画像処理をするモジュール 基本処理としてはフィルタとか(こちら) numpyのアレイの作りに関する記事 numpy.arrayの演算の速さに関する記事(コピーする操作としない操作…

パイソンをいじる

pythonを使い始める人とともに、しばしpythonをいじってみることにする $ python でLINUX内の"python"環境に入る >>> a=1 >>> b=3 >>> print a+1 とか #! /usr/bin/env python print "hello, python" なる"hello.py"なるファイルを $ python hello.py とかや…