我有这样的数据框......
a_return b_return bc_ratio instrument_holding
0 NaN NaN -0.165286 a
1 0.996474 1.013166 -0.164637 a
2 0.997730 0.993540 -0.170058 a
3 1.024294 1.024318 -0.184530 a
4 1.019071 1.047297 -0.148644 a
5 0.992243 1.008210 -0.188752 a
6 1.010331 1.039020 -0.098413 a
7 0.989542 0.991899 0.025051 b
8 1.005197 1.002527 -0.025051 b
9 0.990755 1.002352 -0.099800 a
10 1.006241 0.998375 -0.078643 b
Run Code Online (Sandbox Code Playgroud)
我想添加一个名为"log_ret"的列,其中"a_return"或"b_return"中的值将根据"instrument_holding"列中的值使用.像这样...
a_return b_return bc_ratio instrument_holding log_ret
0 NaN NaN -0.165286 a NaN
1 0.996474 1.013166 -0.164637 a 0.996474
2 0.997730 …Run Code Online (Sandbox Code Playgroud) 我最近阅读了本教程。我从教程中获得了训练有素的模型,我想与docker一起使用它,因此我可以向其发送任意字符串,并从模型中获取预测。
我还通读了本教程,以了解如何与Docker一起使用。但是我不理解如何通过接受输入参数来保存模型。例如:
curl -d '{"instances": [1.0, 2.0, 5.0]}' \
-X POST http://localhost:8501/v1/models/half_plus_two:predict
Run Code Online (Sandbox Code Playgroud)
half_plus_two模型如何知道如何处理instances参数?
在文本生成教程中,有一种称为的方法generate_text可以处理生成预测。
def generate_text(model, start_string):
# Evaluation step (generating text using the learned model)
# Number of characters to generate
num_generate = 1000
# Converting our start string to numbers (vectorizing)
input_eval = [char2idx[s] for s in start_string]
input_eval = tf.expand_dims(input_eval, 0)
# Empty string to store our results
text_generated = []
# Low temperatures results in more predictable …Run Code Online (Sandbox Code Playgroud)