""" Importing libraries """
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression, LogisticRegression
from sklearn.svm import SVC
import pickle

iris = datasets.load_iris()         # loading the dataset
# print(iris)

# segregating the input values and output values into two arrays
X = iris.data           # input value array
Y = iris.target         # output/target value array

# splitting the data into training and testing part
x_train, x_test, y_train, y_test = train_test_split(X, Y)

# importing LinearRegression, LogisticRegression and Support vector classifier model
lin_reg = LinearRegression()
log_reg = LogisticRegression()
svc_model = SVC()

# training these model
lin_reg = lin_reg.fit(x_train, y_train)
log_reg = log_reg.fit(x_train, y_train)
svc_model = svc_model.fit(x_train, y_train)

# printing score of these model on testing data
print(f"Linear Regression score: {lin_reg.score(x_test, y_test)}")
print(f"Logistic Regression score: {log_reg.score(x_test, y_test)}")
print(f"Support Vector Classifier score: {svc_model.score(x_test, y_test)}")

# saving the model into a pickle file
pickle.dump(lin_reg, open('lin_model.pkl', 'wb'))
pickle.dump(log_reg, open('log_model.pkl', 'wb'))
pickle.dump(svc_model, open('svc_model.pkl', 'wb'))

