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
| 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) |
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
| %%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() |
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,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") |
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) | |
| 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") |
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(decision_tree, 'decision_tree_titanic') |
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
| #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 |
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(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") |
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
| --- | |
| - 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 |
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
| Resources: | |
| Ec2Instance: | |
| Type: 'AWS::EC2::Instance' | |
| Properties: | |
| SecurityGroups: | |
| - !Ref InstanceSecurityGroup | |
| KeyName: mykey | |
| ImageId: '' | |
| InstanceSecurityGroup: | |
| Type: 'AWS::EC2::SecurityGroup' |
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
| version: "3.9" # optional since v1.27.0 | |
| services: | |
| web: | |
| build: . | |
| ports: | |
| - "5000:5000" | |
| volumes: | |
| - .:/code | |
| - logvolume01:/var/log | |
| links: |