質問編集履歴
1
エラーコードを全文記載しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,8 +118,102 @@
|
|
118
118
|
|
119
119
|
|
120
120
|
|
121
|
+
> ---------------------------------------------------------------------------
|
122
|
+
|
123
|
+
> IndexError Traceback (most recent call last)
|
124
|
+
|
125
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/model.py in get_context(cls, error_if_none)
|
126
|
+
|
127
|
+
> 212 try:
|
128
|
+
|
129
|
+
> --> 213 candidate = cls.get_contexts()[idx] # type: Optional[T]
|
130
|
+
|
131
|
+
> 214 except IndexError as e:
|
132
|
+
|
133
|
+
>
|
134
|
+
|
135
|
+
> IndexError: list index out of range
|
136
|
+
|
137
|
+
>
|
138
|
+
|
139
|
+
> During handling of the above exception, another exception occurred:
|
140
|
+
|
141
|
+
>
|
142
|
+
|
143
|
+
> TypeError Traceback (most recent call last)
|
144
|
+
|
145
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
|
146
|
+
|
147
|
+
> 32 try:
|
148
|
+
|
149
|
+
> ---> 33 model = Model.get_context()
|
150
|
+
|
151
|
+
> 34 except TypeError:
|
152
|
+
|
153
|
+
>
|
154
|
+
|
155
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/model.py in get_context(cls, error_if_none)
|
156
|
+
|
157
|
+
> 217 if error_if_none:
|
158
|
+
|
159
|
+
> --> 218 raise TypeError("No %s on context stack"%str(cls))
|
160
|
+
|
161
|
+
> 219 return None
|
162
|
+
|
163
|
+
>
|
164
|
+
|
165
|
+
> TypeError: No <class 'pymc3.model.Model'> on context stack
|
166
|
+
|
167
|
+
>
|
168
|
+
|
169
|
+
> During handling of the above exception, another exception occurred:
|
170
|
+
|
171
|
+
>
|
172
|
+
|
173
|
+
> TypeError Traceback (most recent call last)
|
174
|
+
|
175
|
+
> <ipython-input-3-3c1692da3682> in <module>
|
176
|
+
|
177
|
+
> 1 # レビュー評価4.5に対して、取得した軌跡(trace)を引数に渡して事後分布の確認
|
178
|
+
|
179
|
+
> 2 trace_of_review_num_2 = get_posterior_review_rate_trace(
|
180
|
+
|
181
|
+
> ----> 3 review_rate=4.5, review_num=2)
|
182
|
+
|
183
|
+
>
|
184
|
+
|
185
|
+
> <ipython-input-1-04c321e246cf> in get_posterior_review_rate_trace(review_rate, review_num)
|
186
|
+
|
187
|
+
> 30 # name は確率変数名
|
188
|
+
|
189
|
+
> 31 def get_posterior_review_rate_trace(review_rate, review_num):
|
190
|
+
|
191
|
+
> ---> 32 _review_rate = pm.Uniform(name='review_rate', lower=0, upper=1)
|
192
|
+
|
193
|
+
> 33 review_rate_0_to_1 = (review_rate - 1) * 0.25
|
194
|
+
|
195
|
+
> 34 print('0~1の範囲でのレビュー評価 : ', review_rate_0_to_1)
|
196
|
+
|
197
|
+
>
|
198
|
+
|
199
|
+
> ~/anaconda3/lib/python3.7/site-packages/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
|
200
|
+
|
201
|
+
> 33 model = Model.get_context()
|
202
|
+
|
203
|
+
> 34 except TypeError:
|
204
|
+
|
205
|
+
> ---> 35 raise TypeError("No model on context stack, which is needed to "
|
206
|
+
|
207
|
+
> 36 "instantiate distributions. Add variable inside "
|
208
|
+
|
209
|
+
> 37 "a 'with model:' block, or use the '.dist' syntax "
|
210
|
+
|
211
|
+
>
|
212
|
+
|
121
213
|
> 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.
|
122
214
|
|
123
215
|
|
124
216
|
|
217
|
+
|
218
|
+
|
125
219
|
上記を解消するためのコードを教えていただけませんでしょうか。
|