In [ ]:
#Ajouter cette celule à la fin du notebook de classification
#enregistrer le pkl
import pickle
with open('scaler_CLASSIFICATION_direction.pkl', 'wb') as f:
    pickle.dump((Final_model), f)

print("Modèle et scaler enregistrés dans 'scaler_CLASSIFICATION_direction.pkl'")
In [7]:
#Importer le modèle à partir du fichier enregistré
import pandas as pd
import pickle
loaded_model = pickle.load(open('scaler_CLASSIFICATION_direction.pkl', 'rb'))
In [5]:
id = int(input("id"))
MMSI = int(input("MMSI"))
LAT = float(input("LAT"))
LON = float(input("LON"))
SOG = float(input("SOG"))
COG = float(input("COG"))
Heading = int(input("Heading"))
Status = int(input("Status"))
Length = int(input("Length"))
Width = int(input("Width"))
Draft = float(input("Draft"))
Cargo = int(input("Cargo"))
In [9]:
bat = pd.DataFrame([id, MMSI, LAT, LON, SOG, COG, Heading, Status, Length, Width, Draft, Cargo])
print(loaded_model.predict(bat.T))
[80]
C:\Users\Anis\anaconda3\Lib\site-packages\sklearn\utils\validation.py:2749: UserWarning: X does not have valid feature names, but KNeighborsClassifier was fitted with feature names
  warnings.warn(
In [ ]: