0

GPR を使用してさまざまな燃料の燃焼特性を分析および予測するスクリプトを作成しています。テスト セットの出力が良好で、95% 信頼区間を追加したいと考えています。間隔を実装しようとすると、ひどい結果が得られます。助けを送ってください。

#Gaussian Predictions for Ignition Delay
#September 14 2021

%matplotlib inline
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns

from sklearn.metrics import mean_absolute_error as mae
from sklearn.model_selection import train_test_split
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C

#gpr = GaussianProcessRegressor()

kernel = C(1.0, (1e-3, 1e3))*RBF(10, (1e-2, 1e2))
gpr = GaussianProcessRegressor(kernel = kernel, n_restarts_optimizer = 9, alpha = 0.1, normalize_y = True)
gpr.fit(x_train, y_train)
y_prediction, std = gpr.predict(x_test, return_std = True)

confidence = std*1.96/np.sqrt(len(x_test))
confidence = confidence.reshape(-1,1)

# Plot the function, the prediction and the 95% confidence interval based on
# the MSE
plt.figure()

plt.plot(x_train, y_train, "b.", markersize=10, label="Observations")
plt.fill(x_test,
         y_prediction-confidence,
         y_prediction+confidence,
         alpha=0.3,
         fc="b",
         ec="None",
         label="95% confidence interval",
)         #this plots confidence interval and fit it to my data

plt.plot(x_test, y_prediction, "r.", markersize=10, label="Prediction")
```[enter image description here][1]


  [1]: https://i.stack.imgur.com/PItpi.png
4

1 に答える 1