解决问题:Intel MKL ERROR: Parameter 6 was incorrect on entry to DGELSD.(进入DGELSD时,参数6不正确。)
程序员文章站
2022-07-22 14:33:59
import numpy as npimport matplotlib.pyplot as pltimport pandas as pdfrom sklearn.preprocessing import MinMaxScalerdata =pd.read_excel("数据.xlsx",header=None)data0=np.array(data.iloc[:1400,1])#定义x、y散点坐标x = range(1,1401)y = data0#用n次多项式拟合f1 = np....
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.preprocessing import MinMaxScaler data =pd.read_excel("数据.xlsx",header=None) data0=np.array(data.iloc[:1400,1]) #定义x、y散点坐标 x = range(1,1401) y = data0 #用n次多项式拟合 f1 = np.polyfit(x,y,3) p1 = np.poly1d(f1) #也可使用yvals=np.polyval(f1, x) yvals = p1(x) #拟合y值 #绘图 plt.figure(figsize=(10, 8)) plot1 = plt.plot(x, y, '.',label='original values') plot2 = plt.plot(x, yvals, 'r',label='polyfit values') plt.xlabel('x') plt.ylabel('y') plt.legend(loc=4) #指定legend的位置右下角 plt.title('polyfitting') plt.show() def mape(y_true, y_pred): """ 参数: y_true -- 测试集目标真实值 y_pred -- 测试集目标预测值 返回: mape -- MAPE 评价指标 """ n = len(y_true) mape = sum(np.abs((y_true - y_pred) / y_true)) / n * 100 return mape def mae_value(y_true, y_pred): """ 参数: y_true -- 测试集目标真实值 y_pred -- 测试集目标预测值 返回: mae -- MAE 评价指标 """ n = len(y_true) mae = sum(np.abs(y_true - y_pred)) / n return mae def mse(y_true, y_pred): error = [] for k in range(len(y_pred)): error.append(y_true[k] - y_pred[k]) squaredError = [] absError = [] for val in error: squaredError.append(val * val) # target-prediction之差平方 absError.append(abs(val)) # 误差绝对值 MSE = sum(squaredError) / len(squaredError) return MSE def sse(y_true, y_pred): sse = np.sum((y_true - y_pred) ** 2) return sse def r2(y_true, y_pred): sst = np.sum((y_true - np.mean(y_true)) ** 2) r2 = 1 - (sse(y_true, y_pred) / sst) # r2_score(y_actual, y_predicted, multioutput='raw_values') return r2 print("mape:",mape(y,yvals)) print("mse:",mse(y,yvals)) print("mae:",mae_value(y,yvals)) print("sse:",sse(y,yvals)) print("r2:",r2(y,yvals))
运行代码时显示如下:
最后找出原因是数据里含有空白项,删除数据的空白即可 。
本文地址:https://blog.csdn.net/weixin_43699652/article/details/107434536