Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save machine learning model

# fit the model
model.fit(X_train, y_train)

# save the model
import pickle
pickle.dump(model, open("model.pkl", "wb"))

# load the model
model = pickle.load(open("model.pkl", "rb"))

# use model to predict
y_pred = model.predict(X_input)
Comment

save machine learning model python

model.fit(X_train, Y_train)
# save the model to disk
filename = 'finalized_model.sav'
pickle.dump(model, open(filename, 'wb'))
 
# load the model from disk
loaded_model = pickle.load(open(filename, 'rb'))
result = loaded_model.score(X_test, Y_test)
Comment

PREVIOUS NEXT
Code Example
Python :: difference between w+ and r+ in python 
Python :: python make txt file 
Python :: how to increase the figure size in matplotlib 
Python :: how to set the screen brightness using python 
Python :: what to do in python when you get pygame.Surface object is not callable 
Python :: plt vertical line 
Python :: The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. 
Python :: selenium change window size 
Python :: pandas filter string contain 
Python :: python get list of all open windows 
Python :: falsy python 
Python :: put comma in numbers python 
Python :: make y axis start at 0 python 
Python :: Generate random image np array 
Python :: 2d list comprehension python 
Python :: python3 iterate through indexes 
Python :: how to save a png seaborn pandas 
Python :: ctypes run as administrator 
Python :: show rows with a null value pandas 
Python :: month from datetime pandas 
Python :: jupyter print full dataframe 
Python :: how to plot kmeans graph 
Python :: create new django app 
Python :: how to install gym 
Python :: renomear colunas pandas 
Python :: how to get input in tkinter 
Python :: lcm math python library 
Python :: python copy file and rename 
Python :: python diamond print 
Python :: get video width and height cv2 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =