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 :: print numpy version 
Python :: pandas to csv without header 
Python :: change type of array python 
Python :: return maximum of three values in python 
Python :: python requirments.txt 
Python :: confidence intervals in python 
Python :: read file line by line into list 
Python :: eigenvectors python 
Python :: Could not find a version that satisfies the requirement psycopg2=2.8 (from pgcli) (from versions: 2.7.5, 2.7.6, 2.7.6.1, 2.7.7) 
Python :: complex phase python 
Python :: pytest ignore warnings 
Python :: filter by row contains pandas 
Python :: cannot remove column in pandas 
Python :: python print float in scientific notation 
Python :: autoclicker in python 
Python :: read database pandas 
Python :: py get mouse coordinates 
Python :: python iterate dictionary key value 
Python :: time it in jupyter notebook 
Python :: python blender select object by name 
Python :: importying listviewin django 
Python :: python temporary directory 
Python :: image capture from camera python 
Python :: pandas series to string without index 
Python :: python converting float to binary 
Python :: PRINT VS RETURN IN PYTHON 
Python :: display max rows pandas 
Python :: mysql config not found 
Python :: how to find if a value is even or odd in python 
Python :: NotImplementedError: Please use HDF reader for matlab v7.3 files 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =