We can use joblib to save or load a machine learning model. We can train a machine learning model and then, save it in a file. After that, we can load the model from the saved file at any time and test or evaluate the model.
For example, we can use the following Python code to save a machine learning model in a file using the Python joblib module.
from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression import pandas from joblib import dump data = pandas.read_csv("diabetes.csv") D = data.values X = D[:, :-1] y = D[:, -1] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, shuffle=True, random_state=1) classifier = LogisticRegression(solver="liblinear") classifier.fit(X_train, y_train) dump(classifier, "diabetes_classification_joblib.sav")
Here, we are first reading the Pima Indians Diabetes dataset. The dataset contains various predictor variables such as the number of pregnancies the patient has had, the BMI, insulin level, age, etc. A machine learning model can learn from the …






0 Comments