如果您想返回均方误差,可以将目标函数修改为:
```python
def objective_function(x):
weights = x[:11]
T = x[11]
composite_index = pearson_fusion(data, weights)
N = len(composite_index)
dt = T/N
t = np.linspace(0, T, N+1)
dW = np.sqrt(dt)*np.random.randn(N)
W = np.cumsum(dW)
W = np.insert(W, 0, 0)
weights = np.repeat(weights, N+1).reshape((11,N+1))
Z =np.dot(weights, W.flatten())
predicted_failure_time = t[np.argmax(Z > 0.9*np.max(Z))]
mse = ((predicted_failure_time - actual_failure_time)**2)/len(data.iloc[:-1])
return mse
```
在这个修改后的目标函数中,我们计算了预测故障时间和实际故障时间之间的均方误差,并将其作为目标函数的返回值。