2016-12-05 27 views

回答

0

這是一個古老的問題,但對於後來的任何人來說,這些片段就是我用來評估失落關係的片段。我希望有人會覺得它有用。

# Collect errors to evaluate performance. 
errorlist = []; 

# Fit model by passing multiple times. 
numberOfIterations = 5; 
for i in range(numberOfIterations): 

    # Fit the model 
    regressor.fit(x=X,y=Y,steps=5000) 

    # Get the error 
    y = list(regressor.predict(X, as_iterable=True)) 
    error = mean_squared_error(Y,y) 
    errorlist = np.append(errorlist,error) 

    # Inform the user about remaining iterations 
    print("Remaining:",numberOfIterations-i) 

並繪製你收集到這裏的錯誤,你可以很容易地通過matplotlib做到這一點。

# Plot errors 
plt.figure(1) 
plt.plot(errorlist,'g'); 
plt.title("Mean Squarred Error") 
plt.xlabel("Batch Iteration Number (x5000)") 
plt.ylabel("Error") 
相關問題