Skip to content

Instantly share code, notes, and snippets.

# List all saved artifacts
lineapy.catalog()
pd.DataFrame(test_results, index=['Mean absolute error [MPG]']).T
#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',
#Linear regression Model
linear_model = tf.keras.Sequential([
normalizer,
layers.Dense(units=1)
])
linear_model.predict(train_features1[:10])
linear_model.layers[1].kernel
model_artifact = lineapy.save(dnn_model, 'dnn_model')
#Assets written to: ram://044e58dc-eeb9-42b8-ab3a-b99c11c66927/assets
#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)
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)
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")
# 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
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='')