This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ['CUDA_LAUNCH_BLOCKING'] = "1" | |
import torch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importations. | |
import matplotlib.pyplot as plt | |
# Valeurs pour l'exemple. | |
x = [3, 1, 4, 6, 7] | |
y = [2, 4, 7, 5, 4] | |
# Tracé. | |
plt.scatter(x, y) | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importations. | |
import matplotlib.pyplot as plt | |
# Valeurs pour l'exemple. | |
x = [4, 1, 3, 5, 6] | |
y = [2, 7, 2, 9, 5] | |
# Tracé. | |
plt.scatter(x, y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.io as pio | |
# La ligne suivante assure que les sorties de plotly fonctionnent dans différents endroits. | |
pio.renderers.default = "plotly_mimetype+notebook" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
value = 7 / 3 | |
print(f"{value:.2e}") | |
>>> 4.29e-01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
max_tensor = torch.maximum(x1, x2) # où x1 et x2 sont deux tenseurs que vous avez définis au préalable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cp <FICHIER_SOURCE> <FICHIER_DESTINATION> | |
# Exemple: cp dossier_source/fichier.txt dossier_destination/fichier.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_variable = 1 # on a une variable my_variable à laquelle on affecte une valeur quelconque, ici 1. | |
variable_name = f"{a=}"[:-2] | |
# variable_name est le nom de notre variable, en l'occurrence, il s'agit de la chaîne de caractères "my_variable". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
r = requests.get(url) # où url est votre lien. | |
with open(file_name, "wb") as file: # où file_name est le nom du fichier que vous voulez créer. | |
file.write(r.content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frequencies = df.value_counts(subset=column_name) | |
# df est une dataframe que vous avez pré-définie | |
# column_name est le nom de la colonne dont vous comptez les occurrences de chaque valeur | |
# frequencies est une dataframe qui indique le nombre d'occurrences des valeurs de column_name | |
# Pour accéder précisément au nombre d'occurrences d'une valeur de column_name, utiliser la ligne suivante: | |
value = df.value_counts(subset=column_name)[value_name] |
NewerOlder