Skip to content
Extraits de code Groupes Projets
Valider b3489152 rédigé par Céline's avatar Céline
Parcourir les fichiers

machine learning / yml

parent 9df3c37c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #3411 en échec
image: python:3.9
stages:
- build
- test
- export
# Build stage
build:
stage: build
script:
- python machine_learning.py
# Test stage
test:
stage: test
script:
- pytest test_prediction.py
# Export stage
export:
stage: export
script:
- mv digits_model.joblib artifacts/
\ No newline at end of file
from joblib import dump
from sklearn import svm
from sklearn import datasets
def train_model():
model = svm.SVC()
X, y = datasets.load_digits(return_X_y=True)
model.fit(X, y)
return model
def export_model(model):
dump(model, './digits_model.joblib')
def start():
model = train_model()
export_model(model)
print('Model successfully exported.')
if __name__ == '__main__':
start()
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from machine_learning import train_model
def test_inference_sample():
model = train_model()
X, _ = datasets.load_digits(return_X_y=True)
prediction = model.predict(X[0:1])[0]
assert prediction == 0
def test_inference_batch():
model = train_model()
X, _ = datasets.load_digits(return_X_y=True)
predictions = model.predict(X[0:100])
assert np.all(predictions < 10)
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter