I am working on a team that is responsible for designing a machine learning model for anomaly detection in self-driving cars. My goal with the team is to identify and respond to unexpected situations or malfunctions in Teslas during operation. I will present my requirements for data preparation to the manufacturing team. 1) During Tesla operations, there are many different types of malfunctions or unexpected scenarios that can occur. Using just a single binary target variable for all anomalies will not be as effective as creating a binary indicator for each anomaly. With that being said, the target variable still remains the same as 0 showing no malfunctions and 1 showing a malfunction or unexpected scenario. With that, there will be four main categories that need to be reported as either showing a malfunction (1) or not (0). The vehicle manufacturing team will need to prepare a response as 1 or 0 for “Sensor Failure”, “Unexpected Obstacle”, “Software Malfunction”, and “Structural Build Issue”. 2) During operation, there is are features on the Tesla that provide critical feedback on detecting anomalies. These critical variables would fall into three main categories of Sensor Data, Environment Data, and Software Data. Data collected from the sensors would be from ultrasonic sensors, cameras, GPS, thermometers, and speedometer. Data collected from environment would be altitude, weather condition, speed, location, and road category. Lastly, from structure/build, exterior condition and tire pressure. 3) As far as performance goes, the 0 and 1 variables will be useful in determining weather there was a “Sensor Failure”, “Unexpected Obstacle”, “Software Malfunction”, and “Structural Build Issue”. By collecting data from theses categories, where applicable, a 1 or 0 response will be provided for ultrasonic sensors, cameras, GPS, thermometers, and speedometer will either be showing that the feature is working (0) or has a malfunction (1). For the rest of the textual variables, there will be a value associated. By using textual and binary variables, a conclusion may not be drawn as easily and may take longer to parse through. However, the results hopefully we be more accurate. By having many different variables, the model is more precise. By having a binary variable implemented into the model, the specificity of the model is more likely to be accurate. 4) Ultimately, self-driving cars have to take into account not only software internal factors but external environmental factors. By using this model, it does just that. This could enhance the accuracy of predicting the safety and reliability of the vehicle before it is launched.
The marketing team at Lenovo has requested that I analyze their new marketing campaign’s impact and suggest way to enhance its effectiveness. To begin, I would select variables of key performance indicators. I would derive these by creating a multiple linear regression model to determine which variables were closely correlated. Depending on the campaigns exact data, I would consider factors such as Null and NA variables especially if the data is unethical or does not have significant value to the research. From the clean data, I would create a predictor. For example if the campaign was marketing, I would predict whether the email was opened (1) or unopened (0) based on date email was received, company email was sent to, years the person has been with the company, and many more factors. This could help in determining who to email and also narrow down who is most likely to repsond. Testing this theory,
Dealing with this data set, we were looking at 43,431 entries. Of the 19: columns, package_id, from_area_id, to_area_id, from_city_id to_city_id, to_date, to_lat, to_long, from_lat, from_long, all contained the value “NULL” to represent NA values. The row still contains a variable, using na.omit would not work. Because of this, my solution to this data would be to replace the “NULL” variable with NA. From achieving a now usable NA value, I identified the number of NA values in each column. The columns with the most NA values were package_id, from_city_id, and to_city_id. From these columns, over half of their data was NA. With little usable data, I deleted these columns. For a quantifiable decision making threshold, if over half of the data was NA, then the column should be deleted. I am now left with 16 columns with 19,107 rows. Looking at the chart below you can see that there are no longer NULL or NA values in the data.
setwd("/Users/lululemken/Desktop/Data Mining/Final Exam ")
### Import the Yourcabs data
df <- read.csv("Taxi_cancelation.csv")
df <- df[,c("id","user_id","vehicle_model_id","travel_type_id","from_area_id", "to_area_id",
"from_date", "to_date","online_booking","mobile_site_booking","booking_created",
"from_lat", "to_lat", "to_long", "from_long","Car_Cancellation")]
df <- replace(df, df == "NULL", NA)
df <- na.omit(df)
colSums(is.na(df))
## id user_id vehicle_model_id travel_type_id
## 0 0 0 0
## from_area_id to_area_id from_date to_date
## 0 0 0 0
## online_booking mobile_site_booking booking_created from_lat
## 0 0 0 0
## to_lat to_long from_long Car_Cancellation
## 0 0 0 0
# Preprocess the Data, packages are unable to be installed, therefore could not load the suggested preprocessing data for the date and time.
#install.packages("geosphere")
#library(geosphere)
library(ggplot2)
ggplot(df, aes(x = factor(c(travel_type_id)), fill = factor(Car_Cancellation))) +
geom_bar(position = "dodge") +
labs(title = "Car Cancellation by Travel Type",
x = "Travel Type ID",
y = "Count") +
scale_fill_manual(values = c("0" = "lightblue", "1" = "blue"),
labels = c("No Cancellation", "Cancellation")) +
theme_minimal()
library(ggplot2)
ggplot(df, aes(x = factor(c(online_booking)), fill = factor(Car_Cancellation))) +
geom_bar(position = "dodge") +
labs(title = "Car Cancellation by Travel Type",
x = "Travel Type ID",
y = "Count") +
scale_fill_manual(values = c("0" = "lightblue", "1" = "blue"),
labels = c("No Cancellation", "Cancellation")) +
theme_minimal()
## [1] "Mean Absolute Error (MAE): 0.162745545425759"
## [1] "Root Mean Squared Error (RMSE): 0.310068984097493"
## [1] "R-Squared (Coefficient of Determination): 0.179933778189491"
## Loading required package: lattice
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
##
## Attaching package: 'randomForest'
## The following object is masked from 'package:ggplot2':
##
## margin