是否可以实时拟合线性回归模型?

时间:2019-07-28 14:50:26

标签: python machine-learning scikit-learn regression linear-regression

是否可以实时拟合像NN这样的线性回归?如下所示。这仅是示例,在这种情况下不需要。但是,就我而言,我需要实时拟合。正如您在底部看到的那样,线性回归始终可以预测最新拟合和变量final_output_row的输出。显然这不好。任何想法是否有可能使其像在神经网络中那样工作,在该网络中我可以分别拟合每一行并且模型正在正确学习?

    while(True):

        model123 = joblib.load('path')

        for index, row in df_data.iterrows():

            input_row = []

            print('iteration no. ' + str(index))

            for key in input:
                input_row.append(row[key])

            final_input_row = np.array(input_row).reshape(1, -1)

            output_row = []

            for key in output:
                output_row.append(row[key])

            final_output_row = np.array(output_row).reshape(1, 1)

            result = model123.predict(final_input_row)
            print(final_output_row)
            print(result)
            model123.fit(final_input_row, final_output_row)

        joblib.dump('path')

它返回类似这样的内容

...
iteration no. 225
[[109.9]]
[[59.]]
iteration no. 226
[[73.69]]
[[109.9]]
iteration no. 227
[[131.]]
[[73.69]]
iteration no. 228
[[88.63]]
[[131.]]
iteration no. 229
[[63.13]]
[[88.63]]
iteration no. 230
[[85.63]]
[[63.13]]
iteration no. 231
[[88.19]]
[[85.63]]
iteration no. 232
[[164.]]
[[88.19]]
iteration no. 233
[[127.8]]
[[164.]]
iteration no. 234
[[213.1]]
[[127.8]]
iteration no. 235
[[89.63]]
[[213.1]]
iteration no. 236
[[135.1]]
[[89.63]]
...

0 个答案:

没有答案