質問編集履歴
1
エラーコードを全文記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -58,6 +58,53 @@
|
|
58
58
|
ここで、以下のエラーが発生してしまいます。
|
59
59
|
|
60
60
|
|
61
|
+
> ---------------------------------------------------------------------------
|
62
|
+
> IndexError Traceback (most recent call last)
|
63
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/model.py in get_context(cls, error_if_none)
|
64
|
+
> 212 try:
|
65
|
+
> --> 213 candidate = cls.get_contexts()[idx] # type: Optional[T]
|
66
|
+
> 214 except IndexError as e:
|
67
|
+
>
|
68
|
+
> IndexError: list index out of range
|
69
|
+
>
|
70
|
+
> During handling of the above exception, another exception occurred:
|
71
|
+
>
|
72
|
+
> TypeError Traceback (most recent call last)
|
73
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
|
74
|
+
> 32 try:
|
75
|
+
> ---> 33 model = Model.get_context()
|
76
|
+
> 34 except TypeError:
|
77
|
+
>
|
78
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/model.py in get_context(cls, error_if_none)
|
79
|
+
> 217 if error_if_none:
|
80
|
+
> --> 218 raise TypeError("No %s on context stack"%str(cls))
|
81
|
+
> 219 return None
|
82
|
+
>
|
83
|
+
> TypeError: No <class 'pymc3.model.Model'> on context stack
|
84
|
+
>
|
85
|
+
> During handling of the above exception, another exception occurred:
|
86
|
+
>
|
87
|
+
> TypeError Traceback (most recent call last)
|
88
|
+
> <ipython-input-3-3c1692da3682> in <module>
|
89
|
+
> 1 # レビュー評価4.5に対して、取得した軌跡(trace)を引数に渡して事後分布の確認
|
90
|
+
> 2 trace_of_review_num_2 = get_posterior_review_rate_trace(
|
91
|
+
> ----> 3 review_rate=4.5, review_num=2)
|
92
|
+
>
|
93
|
+
> <ipython-input-1-04c321e246cf> in get_posterior_review_rate_trace(review_rate, review_num)
|
94
|
+
> 30 # name は確率変数名
|
95
|
+
> 31 def get_posterior_review_rate_trace(review_rate, review_num):
|
96
|
+
> ---> 32 _review_rate = pm.Uniform(name='review_rate', lower=0, upper=1)
|
97
|
+
> 33 review_rate_0_to_1 = (review_rate - 1) * 0.25
|
98
|
+
> 34 print('0~1の範囲でのレビュー評価 : ', review_rate_0_to_1)
|
99
|
+
>
|
100
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
|
101
|
+
> 33 model = Model.get_context()
|
102
|
+
> 34 except TypeError:
|
103
|
+
> ---> 35 raise TypeError("No model on context stack, which is needed to "
|
104
|
+
> 36 "instantiate distributions. Add variable inside "
|
105
|
+
> 37 "a 'with model:' block, or use the '.dist' syntax "
|
106
|
+
>
|
61
107
|
> TypeError: No model on context stack, which is needed to instantiate distributions. Add variable inside a 'with model:' block, or use the '.dist' syntax for a standalone distribution.
|
62
108
|
|
109
|
+
|
63
110
|
上記を解消するためのコードを教えていただけませんでしょうか。
|