소스 검색

[DATALAD] Recorded changes

Lucas Gautheron 8 달 전
부모
커밋
063dd22762
3개의 변경된 파일12개의 추가작업 그리고 12개의 파일을 삭제
  1. 9 9
      code/models/dev_siblings.stan
  2. 3 2
      code/models/enumeration.py
  3. 0 1
      code/preprocessing/siblings.py

+ 9 - 9
code/models/dev_siblings.stan

@@ -219,16 +219,16 @@ model {
     
 
     for (k in 1:n_recs) {
-        real chi_mu = exp(
-            log(mu_pop_level[1]) + child_dev_age[children[k]]*age[k]/12.0/10.0+beta_dev*(mu_child_level[children[k],2]+mu_child_level[children[k],3]-mu_pop_level[3]-mu_pop_level[4])*age[k]/12.0/10.0
+        real chi_mu = mu_pop_level[1]*exp(
+            child_dev_age[children[k]]*age[k]/12.0/10.0+beta_dev*(mu_child_level[children[k],2]+mu_child_level[children[k],3]-mu_pop_level[3]-mu_pop_level[4])*age[k]/12.0/10.0
         );
         (truth_vocs[k,1]/1000/recs_duration) ~ gamma(
             alpha_child_level[1],
             alpha_child_level[1]/chi_mu
         );
 
-        real och_mu = exp(
-            log(mu_child_level[children[k],1]) + (child_siblings[children[k]]>0?beta_sib_och:0)
+        real och_mu = mu_child_level[children[k],1] * exp(
+            (child_siblings[children[k]]>0?beta_sib_och:0)
         );
         (truth_vocs[k,2]/1000/recs_duration) ~ gamma(
             alpha_child_level[2],
@@ -236,7 +236,7 @@ model {
         );
         
         (truth_vocs[k,3:]/1000/recs_duration) ~ gamma(
-            alpha_child_level[3:], alpha_child_level[2:]./mu_child_level[children[k],2:]' //'
+            alpha_child_level[3:], alpha_child_level[3:]./mu_child_level[children[k],2:]' //'
         );    
     }
 
@@ -288,16 +288,16 @@ model {
     }
 
     for (g in 1:n_rates) {
-        real chi_mu = exp(
-            log(mu_pop_level[1]) + child_dev_speech_age[speech_rate_child[g]]*speech_rate_age[g]/12.0/10.0 + beta_dev*(speech_rate_child_level[speech_rate_child[g],2]+speech_rate_child_level[speech_rate_child[g],3]-mu_pop_level[3]-mu_pop_level[4])*speech_rate_age[g]/12.0/10.0
+        real chi_mu = mu_pop_level[1]*exp(
+            child_dev_speech_age[speech_rate_child[g]]*speech_rate_age[g]/12.0/10.0 + beta_dev*(speech_rate_child_level[speech_rate_child[g],2]+speech_rate_child_level[speech_rate_child[g],3]-mu_pop_level[3]-mu_pop_level[4])*speech_rate_age[g]/12.0/10.0
         );
         speech_rate[1,g] ~ gamma(
             alpha_child_level[1],
             alpha_child_level[1]/chi_mu
         );
 
-        real och_mu = exp(
-            log(speech_rate_child_level[speech_rate_child[g],1]) + (speech_rate_child_siblings[speech_rate_child[g]]>0?beta_sib_och:0)
+        real och_mu = speech_rate_child_level[speech_rate_child[g],1]*exp(
+            (speech_rate_child_siblings[speech_rate_child[g]]>0?beta_sib_och:0)
         );
         speech_rate[2,g] ~ gamma(
             alpha_child_level[2],

+ 3 - 2
code/models/enumeration.py

@@ -74,6 +74,7 @@ def extrude(self, removed, mode: str = "intersection"):
 def children_siblings(corpus):
     siblings = pd.read_csv("input/siblings.csv")
     siblings = siblings[siblings["corpus"]==corpus].set_index("child_id")
+    siblings["child_id"] = siblings["child_id"].astype(str)
     siblings = siblings["n_siblings"].to_dict()
 
     n = defaultdict(lambda: -1, **siblings)
@@ -213,7 +214,7 @@ def rates(parameters):
     metrics = pipeline.extract()
     metrics = pd.DataFrame(metrics).assign(corpus=corpus, annotator=annotator)
     project.recordings["age"] = project.compute_ages()
-    project.recordings["siblings"] = project.recordings.child_id.map(
+    project.recordings["siblings"] = project.recordings.child_id.astype(str).map(
         children_siblings(corpus)
     )
     metrics = metrics.merge(
@@ -278,7 +279,7 @@ def compile_recordings(corpus):
     am.read()
 
     project.recordings["age"] = project.compute_ages()
-    project.recordings["siblings"] = project.recordings.child_id.map(
+    project.recordings["siblings"] = project.recordings.child_id.astype(str).map(
         children_siblings(corpus)
     )
 

+ 0 - 1
code/preprocessing/siblings.py

@@ -46,7 +46,6 @@ aclew_id = pd.concat([
 
 aclew_id["its"] = aclew_id["its"].str.replace(".its", "")
 
-
 aclew_md = pd.read_csv("input/aclew_md.csv")
 
 recordings = recordings[["corpus", "child_id", "recording_filename", "its_filename"]].merge(