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
| # List all saved artifacts | |
| lineapy.catalog() |
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
| pd.DataFrame(test_results, index=['Mean absolute error [MPG]']).T |
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
| #DNN Model | |
| def build_and_compile_model(norm): | |
| model = keras.Sequential([ | |
| norm, | |
| layers.Dense(64, activation='relu'), | |
| layers.Dense(64, activation='relu'), | |
| layers.Dense(1) | |
| ]) | |
| model.compile(loss='mean_absolute_error', |
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
| #Linear regression Model | |
| linear_model = tf.keras.Sequential([ | |
| normalizer, | |
| layers.Dense(units=1) | |
| ]) | |
| linear_model.predict(train_features1[:10]) | |
| linear_model.layers[1].kernel |
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
| model_artifact = lineapy.save(dnn_model, 'dnn_model') | |
| #Assets written to: ram://044e58dc-eeb9-42b8-ab3a-b99c11c66927/assets |
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
| #The below is the code generated by get_code() method. | |
| import pickle | |
| import lineapy | |
| import tensorflow as tf | |
| from lineapy.utils.utils import prettify | |
| from tensorflow import keras | |
| from tensorflow.keras import layers | |
| normalizer = tf.keras.layers.Normalization(axis=-1) |
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
| train_art = lineapy.get("train_data") | |
| train_art | |
| #LineaArtifact(name='train_data', _version=0) | |
| y_art = lineapy.get("train_labels") | |
| y_art | |
| #LineaArtifact(name='train_labels', _version=0) | |
| model_art = lineapy.get("dnn_model") | |
| model_art | |
| #LineaArtifact(name='dnn_model', _version=0) |
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 | |
| directory = lineapy.to_pipeline( | |
| [train_art.name,y_art.name, model_art.name], | |
| framework = 'AIRFLOW', | |
| pipeline_name = "dnn_pipeline", | |
| dependencies = {'dnn_pipeline_dnn_model':{'dnn_pipeline_train_data','dnn_pipeline_y'}}, | |
| output_dir = os.environ.get("AIRFLOW_HOME","~/airflow")+"/dags") |
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
| # Store the variable as an artifact | |
| train_artifact = lineapy.save(train_features, "train_data") | |
| # Check object type | |
| print(type(train_artifact)) | |
| # Store the variable as an artifact | |
| train_labels = lineapy.save(train_labels, "train_labels") | |
| # Check object type |
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
| dataset = raw_dataset.copy() | |
| dataset.tail() | |
| dataset.isna().sum() | |
| #drop na | |
| dataset = dataset.dropna() | |
| dataset['Origin'] = dataset['Origin'].map({1: 'USA', 2: 'Europe', 3: 'Japan'}) | |
| #one hot encoding | |
| dataset = pd.get_dummies(dataset, columns=['Origin'], prefix='', prefix_sep='') |