简体   繁体   English

model初始训练后如何添加训练数据?

[英]How to add training data to the model after initial training?

I am trying to add data for my scikit-learn model after it has already been trained.我正在尝试为我的 scikit-learn model 添加数据。 For example, I have the data that I used in the beginning (there are about 250 of them).例如,我有我一开始使用的数据(大约有 250 个)。 After that, I need to train this model one more time by calling the function, and so on.之后,我需要通过调用 function 再次训练这个 model,依此类推。 The only thing that came to my mind was to add new values to the existing data array every time and train the model again, but this is very resource-intensive and takes more time.我唯一想到的是每次都为现有数据数组添加新值并再次训练 model,但这非常耗费资源并且需要更多时间。

Is there another way to train the machine learning model?还有另一种训练机器学习 model 的方法吗?

model = LinearRegression().fit(test, result)
reg.predict(task)
### and here I want to add some data, for example one or two examples like:
model.addFit(one_test, one_result)

The short answer in your case (using the sklearn.linear_model.LinearRegression model) is no, it is not possible to add one or two more examples and train without adding this to the original training set and fitting it all at the same time.在您的案例中,简短的回答(使用sklearn.linear_model.LinearRegression模型)是否定的,如果不将其添加到原始训练集中并同时对其进行拟合,则不可能再添加一两个示例并进行训练。 Under the hood , the model is simply using Ordinary Least Squares (described here ) which requires the complete matrix of training data on which to fit your model. However, this algorithm is very fast and in the case of ~ hundreds of training examples, it would be very quick to re-calculate the parameters of the model with each new couple examples. 在引擎盖下,model 只是使用普通最小二乘法(此处描述),它需要完整的训练数据矩阵来拟合您的 model。但是,该算法非常快,并且在大约数百个训练示例的情况下,它用每个新的例子重新计算 model 的参数会很快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM