Poderosa で分割したウインドウを結合する方法
J48(ClassifierTree) classifyInstance & distributionForInstance
Weka の 決定木アルゴリズム(C4.5)の実装 J48 利用時にclassifyInstance と distributionForInstance の仕様が良くわからず、Javadoc 見てもイマイチだったのでソースで確認した。
http://weka.sourceforge.net/doc.dev/weka/classifiers/trees/J48.html
Sourcecode: ClassifierTree#classfiyInstance
/** * Classifies an instance. * * @param instance the instance to classify * @return the classification * @throws Exception if something goes wrong */ public double classifyInstance(Instance instance) throws Exception { double maxProb = -1; double currentProb; int maxIndex = 0; int j; for (j = 0; j < instance.numClasses(); j++) { currentProb = getProbs(j, instance, 1); if (Utils.gr(currentProb, maxProb)) { maxIndex = j; maxProb = currentProb; // find high probability to class } } return maxIndex; // return max probability class's index
Sourcecode: ClassifierTree#distributionForInstance
/** * Returns class probabilities for a weighted instance. * * @param instance the instance to get the distribution for * @param useLaplace whether to use laplace or not * @return the distribution * @throws Exception if something goes wrong */ public final double[] distributionForInstance(Instance instance, boolean useLaplace) throws Exception { double[] doubles = new double[instance.numClasses()]; for (int i = 0; i < doubles.length; i++) { if (!useLaplace) { doubles[i] = getProbs(i, instance, 1); } else { doubles[i] = getProbsLaplace(i, instance, 1); } } return doubles; }
API 呼出前に、instance に 学習時に指定したclass 群を指定しておき、
- classifyInstance であれば、最も確率の高い class の index を返却
- distributionForInstance であれば、class 毎の確率の配列を class の index と揃えた double[] で返却する
ということがわかった。
CakePHP Shell で Apache Solr を使う
CakePHP Shell で Apache Solr を使いたくなったので調査
(1) Apache Soler インストール
(2) pecl solr インストール
(3) extensions 設定
(4) CakePHP で利用するためのモジュール化
どれがどこまで本当に必要か、、pecl PHP と solr-php-client の違いなど。。
https://code.google.com/p/solr-php-client/
pecl solr インストール
CakePHP の DataSource/Model 作成
http://d.hatena.ne.jp/x002dc/20111021/1319210515
PHP 5.4 以降の extension 設定
http://server-setting.info/debian/debian-php54-module-conf.html
jQuery Template vs Pure.js Javascript テンプレート簡易評価
■ jQuery Template
テンプレート内の変数に対し、対応する JSON を渡すことでテンプレートの展開を実現する。
テンプレート
<div>${NAME}</div>
変換処理
$.tmp([{ NAME : "xxx" })
- 良い点:
HTML 構造を意識せず、JSON とのマッピングで変換可能。
- 悪い点:
値の部分にテンプレート用変数が入り込むため、デザイン時のデータを置き換える必要がある。
デザイン変更時にはこの点の注意が必要。
■pure.js
テンプレート
template = "<div>あああ</div>"
変換処理
compile(template).directives.({ 'div' : 'NAME' }).render([{ NAME : "xxx" })
compile(template).autoRender([{ NAME : "xxx" })
- 良い点:
デザイン時のHTML に手を入れずにテンプレート利用可能
- 悪い点:
directives での指定に HTML 構造が入り込むため、変更に弱い(気が)。
autoRender 機能を利用することで構造の取り扱いを意識しなくてよいはずだが
そのためには要素のセレクタが必要となるため、デザイン時の HTML の変更が必要となる。(ただし、セレクタ部分だけなのでデザイン時のサンプルコンテンツは残る)
■結論
直感的に使いやすくデザイン面で変更が多いクラス属性に手を入れる必要がないことから、jQuery Template が、比較的使いやすいかな。と。
ただし、複雑なテンプレートに対しては別途評価が必要なので注意。
Ubuntu 14.04 と RDP(リモートデスクトップ接続)
Ubuntu 14.04 で RDP と思ったのに Unity 問題でうまくいかなかった時に調べたのでメモをしておく。
Ubuntu 14.04 – LXDE Desktop Alternative for XRDP
要するに
- xrdp, xlde 入れて
sudo apt-get install xrdp
sudo apt-get install lxde
- xrdp, xlde 入れて
- xrdp 再起動して
sudo service xrdp restart
- つなげやがれ。
というわけだけど、われら日本人は KeyMap を追加しないといけないのだが。
以下を確認しましょうと。
Apache Samza のプログラミングモデル
動かしついでに Hello Samza のソースを見てみることに。
まずは一覧。
./src/main/java/samza/examples/wikipedia/system/WikipediaConsumer.java
./src/main/java/samza/examples/wikipedia/system/WikipediaFeed.java
./src/main/java/samza/examples/wikipedia/system/WikipediaSystemAdmin.java
./src/main/java/samza/examples/wikipedia/system/WikipediaSystemFactory.java
./src/main/java/samza/examples/wikipedia/task/WikipediaFeedStreamTask.java
./src/main/java/samza/examples/wikipedia/task/WikipediaParserStreamTask.java
./src/main/java/samza/examples/wikipedia/task/WikipediaStatsStreamTask.java
中身は、、、後で。