This file contains 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 matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
import tensorflow as tf | |
from tensorflow import keras | |
from tensorflow.keras import layers |
This file contains 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_path = keras.utils.get_file("auto-mpg.data", "https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data") |
This file contains 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
column_names = ['MPG','Cylinders','Displacement','Horsepower','Weight', | |
'Acceleration', 'Model Year', 'Origin'] | |
raw_dataset = pd.read_csv(dataset_path, names=column_names, | |
na_values = "?", comment='\t', | |
sep=" ", skipinitialspace=True) | |
dataset = raw_dataset.copy() | |
dataset.tail() |
This file contains 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.isna().sum() |
This file contains 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 = dataset.dropna() |
This file contains 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
origin = dataset.pop('Origin') | |
dataset['USA'] = (origin == 1)*1.0 | |
dataset['Europe'] = (origin == 2)*1.0 | |
dataset['Japan'] = (origin == 3)*1.0 | |
dataset.tail() |
This file contains 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_dataset = dataset.sample(frac=0.8,random_state=0) | |
test_dataset = dataset.drop(train_dataset.index) |
This file contains 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
sns.pairplot(train_dataset[["MPG", "Cylinders", "Displacement", "Weight"]], diag_kind="kde") |
This file contains 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_stats = train_dataset.describe() | |
train_stats.pop("MPG") | |
train_stats = train_stats.transpose() | |
train_stats |
This file contains 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_labels = train_dataset.pop('MPG') | |
test_labels = test_dataset.pop('MPG') |
OlderNewer