Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/main/10. Applied Data Science Capstone/05. Predictive Analysis (Classification)/05. Predictive Analysis (Classification).ipynb
Views: 4598
Space X Falcon 9 First Stage Landing Prediction
Assignment: Machine Learning Prediction
Estimated time needed: 60 minutes
Space X advertises Falcon 9 rocket launches on its website with a cost of 62 million dollars; other providers cost upward of 165 million dollars each, much of the savings is because Space X can reuse the first stage. Therefore if we can determine if the first stage will land, we can determine the cost of a launch. This information can be used if an alternate company wants to bid against space X for a rocket launch. In this lab, you will create a machine learning pipeline to predict if the first stage will land given the data from the preceding labs.
Several examples of an unsuccessful landing are shown here:
Most unsuccessful landings are planed. Space X; performs a controlled landing in the oceans.
Objectives
Perform exploratory Data Analysis and determine Training Labels
create a column for the class
Standardize the data
Split into training data and test data
-Find best Hyperparameter for SVM, Classification Trees and Logistic Regression
Find the method performs best using test data
Import Libraries and Define Auxiliary Functions
We will import the following libraries for the lab
This function is to plot the confusion matrix.
Load the dataframe
Load the data
TASK 1
Create a NumPy array from the column Class
in data
, by applying the method to_numpy()
then assign it to the variable Y
,make sure the output is a Pandas series (only one bracket df['name of column']).
TASK 2
Standardize the data in X
then reassign it to the variable X
using the transform provided below.
We split the data into training and testing data using the function train_test_split
. The training data is divided into validation data, a second set used for training data; then the models are trained and hyperparameters are selected using the function GridSearchCV
.
TASK 3
Use the function train_test_split to split the data X and Y into training and test data. Set the parameter test_size to 0.2 and random_state to 2. The training data and test data should be assigned to the following labels.
X_train, X_test, Y_train, Y_test
we can see we only have 18 test samples.
TASK 4
Create a logistic regression object then create a GridSearchCV object logreg_cv
with cv = 10. Fit the object to find the best parameters from the dictionary parameters
.
We output the GridSearchCV
object for logistic regression. We display the best parameters using the data attribute best_params_
and the accuracy on the validation data using the data attribute best_score_
.
TASK 5
Calculate the accuracy on the test data using the method score
:
Lets look at the confusion matrix:
Examining the confusion matrix, we see that logistic regression can distinguish between the different classes. We see that the major problem is false positives.
TASK 6
Create a support vector machine object then create a GridSearchCV
object svm_cv
with cv = 10. Fit the object to find the best parameters from the dictionary parameters
.
TASK 7
Calculate the accuracy on the test data using the method score
:
We can plot the confusion matrix
TASK 8
Create a decision tree classifier object then create a GridSearchCV
object tree_cv
with cv = 10. Fit the object to find the best parameters from the dictionary parameters
.
TASK 9
Calculate the accuracy of tree_cv on the test data using the method score
:
We can plot the confusion matrix
TASK 10
Create a k nearest neighbors object then create a GridSearchCV
object knn_cv
with cv = 10. Fit the object to find the best parameters from the dictionary parameters
.
TASK 11
Calculate the accuracy of tree_cv on the test data using the method score
:
We can plot the confusion matrix
TASK 12
Find the method performs best:
Authors
Joseph Santarcangelo has a PhD in Electrical Engineering, his research focused on using machine learning, signal processing, and computer vision to determine how videos impact human cognition. Joseph has been working for IBM since he completed his PhD.
Change Log
Date (YYYY-MM-DD) | Version | Changed By | Change Description |
---|---|---|---|
2021-08-31 | 1.1 | Lakshmi Holla | Modified markdown |
2020-09-20 | 1.0 | Joseph | Modified Multiple Areas |
Copyright © 2020 IBM Corporation. All rights reserved.