Atomik31 commited on
Commit
0f7bd77
·
1 Parent(s): 6571301

Modification du dockerfile et train.py

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -7
  2. secrets.sh +0 -5
  3. train.py +45 -17
Dockerfile CHANGED
@@ -14,13 +14,8 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
 
15
  COPY --chown=user . /app
16
 
17
- ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
18
- ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
19
- ENV BACKEND_STORE_URI=$BACKEND_STORE_URI
20
- ENV ARTIFACT_STORE_URI=$ARTIFACT_STORE_URI
21
-
22
  CMD mlflow server -p $PORT \
23
  --host 0.0.0.0 \
24
  --allowed-hosts atomik31-mlflow.hf.space \
25
- #--backend-store-uri $BACKEND_STORE_URI \
26
- #--default-artifact-root $ARTIFACT_STORE_URI
 
14
 
15
  COPY --chown=user . /app
16
 
 
 
 
 
 
17
  CMD mlflow server -p $PORT \
18
  --host 0.0.0.0 \
19
  --allowed-hosts atomik31-mlflow.hf.space \
20
+ --backend-store-uri $BACKEND_STORE_URI \
21
+ --default-artifact-root $ARTIFACT_STORE_URI
secrets.sh DELETED
@@ -1,5 +0,0 @@
1
- ARTIFACT_STORE_URI=s3://mlflow-server-dsfs38/
2
- AWS_ACCESS_KEY_ID=AKIA5TMZ4ZTAUA3NEDT2
3
- AWS_SECRET_ACCESS_KEY=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
4
- BACKEND_STORE_URI=postgresql://neondb_owner:npg_F9QsrpxhyXz1@ep-small-math-ag82ufcb-pooler.c-2.eu-central-1.aws.neon.tech/neondb?sslmode=require&channel_binding=require
5
- PORT=7860
 
 
 
 
 
 
train.py CHANGED
@@ -1,17 +1,45 @@
1
- import random
2
- names = ["Jean", "Alice", "Bob", "Chloé", "David", "Marion", "Emma", "Farid", "Gina", "Hugo", "John", "Eva"]
3
-
4
- def people_groups(names, n, p):
5
- random.shuffle(names)
6
-
7
- groups = [] # ✅ Renommé pour éviter la collision
8
- index = 0
9
-
10
- for i in range(n):
11
- group = names[index:index + p]
12
- groups.append(group) # Maintenant c'est clair
13
- index += p
14
-
15
- return groups
16
-
17
- print(people_groups(names, n=4, p=3))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import mlflow
2
+ import pandas as pd
3
+ from sklearn.datasets import load_iris
4
+ from sklearn.linear_model import LogisticRegression
5
+ from sklearn.model_selection import train_test_split
6
+ import os
7
+
8
+ # Load Iris dataset
9
+ iris = load_iris()
10
+
11
+ # Split dataset into X features and Target variable
12
+ X = pd.DataFrame(data = iris["data"], columns= iris["feature_names"])
13
+ y = pd.Series(data = iris["target"], name="target")
14
+
15
+ # Split our training set and our test set
16
+ X_train, X_test, y_train, y_test = train_test_split(X, y)
17
+
18
+ # Set your variables for your environment
19
+ EXPERIMENT_NAME="my-first-mlflow-experiment-iris"
20
+
21
+ # Set tracking URI to your Hugging Face application
22
+ mlflow.set_tracking_uri("https://atomik31-mlflow.hf.space")
23
+
24
+ # Set experiment's info
25
+ mlflow.set_experiment(EXPERIMENT_NAME)
26
+
27
+ # Get our experiment info
28
+ experiment = mlflow.get_experiment_by_name(EXPERIMENT_NAME)
29
+
30
+ # automatically log model info
31
+ mlflow.sklearn.autolog()
32
+
33
+ with mlflow.start_run(experiment_id = experiment.experiment_id):
34
+
35
+ # Instanciate and fit the model
36
+ lr = LogisticRegression()
37
+ lr.fit(X_train.values, y_train.values)
38
+
39
+ # Store metrics
40
+ predicted_qualities = lr.predict(X_test.values)
41
+ accuracy = lr.score(X_test.values, y_test.values)
42
+
43
+ # Print results
44
+ print("LogisticRegression model")
45
+ print("Accuracy: {}".format(accuracy))