This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def makeScoreEdges(posterSearch, gviz, nodes, depth) #指定ノード数だけグラフ描画 | |
#posterHash = @posterDistance[posterSearch].sort{|a, b| b[1][1] <=> a[1][1]} #スコアの高い順に並び替え | |
if !(posterHash = @posterDistance[posterSearch]) | |
return | |
end | |
posterHash = posterHash.slice(0, nodes) | |
nextDepth = depth - 1 | |
if posterHash.last[1][1] / posterHash[0][1][1] > 0.7 #設定値より大きければ出力数変更 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def makeIdealEdges(posterSearch, gviz, idealNodes, depth) | |
posterHash = @posterDistance[posterSearch].sort{|a, b| b[1].length <=> a[1].length} | |
lastLength = posterHash[0][1].length #始めの共有単語数 | |
toDraw = Array.new #出力予定ポスターを回収 | |
#まず共有単語数の一番多いポスターをすべて回収 | |
posterHash.each do |number, words| | |
if words.length != lastLength #同順でなくなったら | |
lastLength = words.length | |
break | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from pylab import * | |
from sympy import * | |
def XDiff(x, y, a): | |
return a / (1.0+ y **2) - x #Toggle switchモデル | |
def YDiff(x, y, a): | |
return a / (1.0+ x **2) - y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from pylab import * | |
def XDiff(x, y, a): | |
return -x + a * y + y * x **2 #Sel'kovモデル | |
def YDiff(x, y, a, b): | |
return b - a * y - y * x **2 | |
def XNull(x, a): #xヌルクライン |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from pylab import * | |
def XDiff(x, y, a): | |
return -a * x + y #Griffithモデル | |
def YDiff(x, y, b): | |
return x **2/ (1.0+ x **2) - b * y | |
def XNull(x, a): #xヌルクライン |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@vector.each_with_index do |attrVector, i| | |
attrVector.each do |line| #属性ごとに行を呼び出す | |
chunkFeasible.each do |chunk, value| | |
if line[0] =~ /#{chunk}/ && !chunkTemp[i].include?(chunk) | |
chunkTemp[i][chunk] = value #行にチャンクが含まれて、そのチャンクがまだ存在していなければ追加 | |
end | |
end | |
end | |
end | |
#作成された新チャンクリストの内容検証 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open ATTR, "<attribute.txt" or die "open: $!"; | |
@attr = (); | |
$i =0; | |
while ($line = <ATTR>) { #属性示唆単語読込み | |
if ($line =~ /^#/) { | |
next; | |
} | |
elsif ($line eq "\n") { | |
$i++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub chromHMM { | |
@lineList = @{$_[0]}; | |
$alpha = 0.02; | |
$K = 5; #分ける状態数 | |
for ($i =0; $i < @lineList; $i++) { | |
foreach $list (@attr) { #示唆単語それぞれについて | |
$j =1; #ベクトル未追加フラグ | |
foreach $line (@{$list}) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ($i =1; $i < @$lineList; $i++) { | |
if (${$trans[$state[$i -1]]}[$state[$i]] <0.4) { #遷移確率が低かったら修正 | |
if ($pk[$state[$i -1]] <0.4) { #遷移前の出現確率も低かったら修正 | |
for ($j =0; $j < @{$vector[$i]}; $j++) { | |
if ((${$vector[$i]}[$j]) && ($j != $stateAttr[$state[$i -1]] -1)) { | |
push @estAttr, $j +1; | |
last; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#隠れ状態から属性を推定する | |
for ($i =0; $i < $K; $i++) { #状態0から順に処理 | |
@attr = (0, 0, 0, 0); #各行の示唆ベクトルを足し合わせていく | |
$t0 =0; | |
for ($j =0; $j < @$lineList; $j++) { | |
if ($state[$j] == $i) { | |
$t0++; #推定状態の数 | |
for ($u =0; $u < @attr; $u++) { #対応するベクトルの要素を足す |
NewerOlder