Skip to content

Commit

Permalink
Merge pull request #45 from raminmohammadi/akhil
Browse files Browse the repository at this point in the history
  • Loading branch information
raminmohammadi authored Jul 9, 2024
2 parents 310991b + 0eafd7d commit bea6b50
Show file tree
Hide file tree
Showing 7 changed files with 1,017 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Labs/Airflow_Labs/Lab_2/dags/Flask_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def failure():

# Function to start Flask app
def start_flask_app():
app.run(host='0.0.0.1', port=5555)
app.run(host='0.0.0.0', port=5555)

#To address this issue, you can use the TriggerDagRunOperator to trigger a separate DAG once start_flask_API starts the Flask server.
# This new DAG can handle the Flask server's lifecycle independently, allowing the current DAG to proceed with sending the email.
Expand Down
1 change: 0 additions & 1 deletion Labs/Airflow_Labs/Lab_2/dags/data/.gitignore

This file was deleted.

1,001 changes: 1,001 additions & 0 deletions Labs/Airflow_Labs/Lab_2/dags/data/advertising.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Labs/Airflow_Labs/Lab_2/dags/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def notify_failure(context):
dag = DAG('Airflow_Lab2',
default_args=default_args,
description='Aiflow-Lab2 DAG Description',
schedule_interval='1 * * * *',
schedule_interval='*/1 * * * *',
catchup=False, #The scheduler, by default, will kick off a DAG Run for any data interval that has not been run since the last data interval (or has been cleared). This concept is called Catchup.
tags=['example'],
owner_links={"Ramin Mohammadi": "https://github.com/raminmohammadi/MLOps/"}
Expand Down
Binary file removed Labs/Airflow_Labs/Lab_2/dags/model/model.sav
Binary file not shown.
26 changes: 13 additions & 13 deletions Labs/Airflow_Labs/Lab_2/dags/src/model_development.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ def data_preprocessing(data):
X_train = ct.fit_transform(X_train)
X_test = ct.transform(X_test)

return X_train, X_test, y_train, y_test
return X_train, X_test, y_train.values, y_test.values

# Build and save a logistic regression model
def build_model(data, filename):
X_train, X_test, y_train, y_test = data

# Define hyperparameter grid for grid search
lr_clf = LogisticRegression()
penalty = ['l1', 'l2']
C = [0.5, 0.6, 0.7, 0.8]
class_weight = [{1: 0.5, 0: 0.5}, {1: 0.4, 0: 0.6}, {1: 0.6, 0: 0.4}, {1: 0.7, 0: 0.3}]
solver = ['liblinear', 'saga']
# Define hyperparameter grid for grid search if required
# lr_clf = LogisticRegression()
# penalty = ['l1', 'l2']
# C = [0.5, 0.6, 0.7, 0.8]
# class_weight = [{1: 0.5, 0: 0.5}, {1: 0.4, 0: 0.6}, {1: 0.6, 0: 0.4}, {1: 0.7, 0: 0.3}]
# solver = ['liblinear', 'saga']

param_grid = dict(
penalty=penalty,
C=C,
class_weight=class_weight,
solver=solver
)
# param_grid = dict(
# penalty=penalty,
# C=C,
# class_weight=class_weight,
# solver=solver
# )

# Create and train a logistic regression model with the best parameters
lr_clf = LogisticRegression()
Expand Down
2 changes: 1 addition & 1 deletion Labs/Airflow_Labs/Lab_2/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ flask
scikit-learn
scipy
pandas
numpy
numpy

0 comments on commit bea6b50

Please sign in to comment.