错误显示:切片索引必须是整数或无或具有 __index__ 方法

问题描述 投票:0回答:0
# create a DataFrame with new samples
new_data = pd.DataFrame({
    'appoitment_booking_time': [10, 11, 12, 13],
    'attendance_mark_hour': [10, 11, 12, 16],
    'checkin_hour': [10, 12, 12, 13],
    'doctor_submit_hour': [11, 12, 13, 8]
})
# convert columns to integer data type
new_data = new_data.astype(int)


# make predictions on new data
predictions = model_fit.predict(steps=4)

# decode the label encoded duration values and store the predicted durations in a list
predicted_durations = []
for prediction in predictions:
    predicted_duration = duration_encoder.inverse_transform([int(prediction)])[0]
    predicted_durations.append(predicted_duration)

print('Predicted consultation durations:', predicted_durations)

我正在尝试使用 arima 模型预测咨询持续时间,在模型拟合和预测值之后,我尝试提供新的 4 个样本以相应地预测 4 个持续时间。但错误指示切片索引必须是整数或无或具有索引方法。我的代码有什么错误吗?谁能帮忙?提前谢谢你。

python typeerror slice prediction
© www.soinside.com 2019 - 2024. All rights reserved.