简体   繁体   中英

Python program running in memory

I have a python program that loads a logistic regression model. I am trying to make a prediction with new incoming data every 5 seconds. The incoming data is passed into the code as a command line argument. The program runs ok but i dont want to keep loading the model every 5 seconds. Is there a way to have the model always loaded in memory? My code is below

loaded_model = joblib.load(r'C:\LR_model.sav')
dataset = ast.literal_eval(sys.argv[1])
result = loaded_model.predict(dataset)

Thank you

memory is bound to the process, so once your process exits it's memory is freed. If you want keep your data loaded, you'll need to rewrite your program as a server process and setup some communication protocol for your client to ask for a new prediction (HTTP seems like a good fit here).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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