Skip to content

Instantly share code, notes, and snippets.

url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data'
column_names = ['MPG', 'Cylinders', 'Displacement', 'Horsepower', 'Weight',
'Acceleration', 'Model Year', 'Origin']
raw_dataset = pd.read_csv(url, names=column_names,
na_values='?', comment='\t',
sep=' ', skipinitialspace=True)
%%capture
import IPython
if (IPython.version_info[0] < 7):
!pip -q install ipython --upgrade
# To load the updated ipython that we have just installed,
# we need to restart the runtime. The exit() command allows
# us to stop the current runtime, and executing the cell after
# it would restart the runtime.
exit()
import os
directory = lineapy.to_pipeline(
[train_art.name,test_art.name,y_art.name, model_art.name],
framework = 'AIRFLOW',
pipeline_name = "titanic_pipeline",
dependencies = {'titanic_pipeline_decision_tree_titanic':{'titanic_pipeline_train_data','titanic_pipeline_test_data','titanic_pipeline_y'}},
output_dir = os.environ.get("AIRFLOW_HOME","~/airflow")+"/dags")
train_art = lineapy.get("train_data")
train_art
#LineaArtifact(name='train_data', _version=0)
test_art = lineapy.get("test_data")
test_art
#LineaArtifact(name='test_data', _version=0)
y_art = lineapy.get("y")
y_art
#LineaArtifact(name='y', _version=0)
model_art = lineapy.get("decision_tree_titanic")
model_artifact = lineapy.save(decision_tree, 'decision_tree_titanic')
#RandomeForestClassifer
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1)
model.fit(X, y)
predictions = model.predict(X_test)
model.score(X, y)
acc_random_forest = round(model.score(X, y) * 100, 2)
acc_random_forest
# Gaussian Naive Bayes
# Store the variable as an artifact
train_artifact = lineapy.save(X, "train_data")
# Check object type
print(type(train_artifact))
# Store the variable as an artifact
test_artifact = lineapy.save(X_test, "test_data")
# Check object type
print(type(test_artifact))
# Store the variable as an artifact
y_artifact = lineapy.save(y, "y")
---
- name: Update web servers
hosts: webservers
remote_user: root
tasks:
- name: Ensure apache is at the latest version
ansible.builtin.yum:
name: httpd
state: latest
Resources:
Ec2Instance:
Type: 'AWS::EC2::Instance'
Properties:
SecurityGroups:
- !Ref InstanceSecurityGroup
KeyName: mykey
ImageId: ''
InstanceSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
version: "3.9" # optional since v1.27.0
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
- logvolume01:/var/log
links: