| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- from Model.Parametre import *
- from Model.profil import profile
- import datetime as dt
- import uuid
- from pathlib import Path
- import shutil
- import os
- import json
- @profile
- def ajouter_res(nom, jour_depart, nb_jours, res, resGlobal, Portefeuille):
- # Création du fichier s'il n'existe pas
- if not os.path.exists(nom):
- with open(nom, "w") as f:
- pass # juste créer le fichier vide
- # Préparer les données à ajouter
- donnees = {
- "jour_depart": jour_depart,
- "nb_jours": nb_jours,
- "res": res,
- "resGlobal": resGlobal,
- "nbVente": Portefeuille.nbVente,
- "nbAchat": Portefeuille.nbAchat,
- "PerteMax": Portefeuille.PerteMax,
- "nbJourGagnant": Portefeuille.JourGagnant,
- "nbJourPerdant": Portefeuille.JourPerdant
- }
- # Ajouter les données au fichier au format JSON
- with open(nom, "a") as f:
- f.write(json.dumps(donnees) + "\n")
- @profile
- def fc_NumeroTest(path):
- # Timestamp compact : AAAAMMJJ_HHMMSS
- timestamp = dt.datetime.now().strftime("%Y%m%d_%H%M%S")
- # Petit identifiant unique si plusieurs lancements simultanés
- uid = uuid.uuid4().hex[:6]
- # Nom final
- nom_dossier = f"Modele_{timestamp}_{uid}"
- return nom_dossier
- def signe(resultat, target):
- signe_resultat = resultat > 0
- signe_target = target > 0
-
- Egal_signe = signe_resultat == signe_target
- return np.sum(Egal_signe)
- def Ecart(resultat, target):
- diff = resultat - target
- return np.mean(diff),np.max(diff),np.min(diff),np.std(diff)
- def AfficheStat(resultat, target):
- nb_Egal = signe(resultat, target)
- print(f"Signe : {nb_Egal}/{np.size(resultat)} soit : {nb_Egal / np.size(resultat)}")
- MoyenEcart,maxEcart,minEcart,stdEcart = Ecart(resultat, target)
- print(f"Ecart :: Moyenne : {MoyenEcart}, max :{maxEcart}, min : {minEcart}, std : {stdEcart}")
|