File size: 671 Bytes
49fdf91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from sklearn.datasets import load_iris
import joblib
import os 
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression

def main():
    # Load the iris dataset
    iris = load_iris()
    X = iris.data[:,0].reshape(-1,1) # single feature
    y = iris.target

    # Split the data into training and testing sets
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

    model = LogisticRegression()
    model.fit(X_train, y_train)

    # Save the model
    os.makedirs('model', exist_ok=True)
    joblib.dump(model, 'model/model.joblib')

if __name__ == '__main__':
    main()