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
País | Idade | Salário | Comprado | |
---|---|---|---|---|
France | 44 | 72000 | No | |
Spain | 27 | 48000 | Yes | |
Germany | 30 | 54000 | No | |
Spain | 38 | 61000 | No | |
Germany | 40 | Yes | ||
France | 35 | 58000 | Yes | |
Spain | 52000 | No | ||
France | 48 | 79000 | Yes | |
Germany | 50 | 83000 | No |
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
# Data Preprocessing | |
# Importing the dataset | |
dataset = read.csv('Data.csv') | |
# Taking care of missing data | |
dataset$Age = ifelse(is.na(dataset$Age), | |
ave(dataset$Age, FUN = function(x) mean(x, na.rm = TRUE)), | |
dataset$Age) | |
dataset$Salary = ifelse(is.na(dataset$Salary), |
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
# Data Preprocessing | |
# Importing the libraries | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
# Importing the dataset | |
dataset = pd.read_csv('Data.csv') | |
X = dataset.iloc[:, :-1].values |
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
# Data Preprocessing | |
# Importing the dataset | |
dataset = read.csv('Data.csv') | |
# Taking care of missing data | |
dataset$Age = ifelse(is.na(dataset$Age), | |
ave(dataset$Age, FUN = function(x) mean(x, na.rm = TRUE)), | |
dataset$Age) | |
dataset$Salary = ifelse(is.na(dataset$Salary), |
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
# K-Nearest Neighbors (K-NN) | |
# Importing the libraries | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
# Importing the dataset | |
dataset = pd.read_csv('Social_Network_Ads.csv') | |
X = dataset.iloc[:, [2, 3]].values |
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
# K-Nearest Neighbors (K-NN) | |
# Importing the dataset | |
dataset = read.csv('Social_Network_Ads.csv') | |
dataset = dataset[3:5] | |
# Encoding the target feature as factor | |
dataset$Purchased = factor(dataset$Purchased, levels = c(0, 1)) | |
# Splitting the dataset into the Training set and Test set |
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
# Classification template | |
# Importing the libraries | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
# Importing the dataset | |
dataset = pd.read_csv('Social_Network_Ads.csv') | |
X = dataset.iloc[:, [2, 3]].values |
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
# Classification template | |
# Importing the dataset | |
dataset = read.csv('Social_Network_Ads.csv') | |
dataset = dataset[3:5] | |
# Encoding the target feature as factor | |
dataset$Purchased = factor(dataset$Purchased, levels = c(0, 1)) | |
# Splitting the dataset into the Training set and Test set |
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
# K-Nearest Neighbors (K-NN) | |
# Importing the libraries | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
# Importing the dataset | |
dataset = pd.read_csv('Social_Network_Ads.csv') | |
X = dataset.iloc[:, [2, 3]].values |