<jupyter_start><jupyter_text>NASA ASTEROID CLASSIFICATION PROJECT  STEPS<jupyter_code>NASA ASTEROID PREDICTION

DATASET FROM  KAGGLE

TOPICS TO BE COVERED:
1.EDA(VISUALIZATION)
2.DATA PREPOCESSING
3.LINEAR REGRESION 
4.DECISION TREE CLASSIFIER
6.LOGISTIC REGRESSION
7.GAUSSIAN NAIVE BAYES
8.FEATURE SELECTION,CROSS VALIDATION ,HYPERPARAMETER TUNING-GRID SEARCH,RANDOMISED CV BOTH,RUC AUC GRAPH FOR ALL THE MODELS
9.PCA AND MULTICOLLINEARITY CHECK<jupyter_output><empty_output><jupyter_text>Brief intro about the dataset:    I thought of using machine learning to predict whether an asteroid could be hazardous or not.Searching on Kaggle, I found NASA’s dataset about some of the asteroids discovered so far. The dataset contains various information about the asteroids and labels each asteroid as hazardous or non-hazardous. The data is about Asteroids and is provided by NEOWS(Near-Earth Object Web Service)The dataset consists of 4687 data instances(rows) and 40 features(columns).'MISS DIST.(ASTRONOMICAL)':it denotes the distance of asteroid from the earth wrt its distance of the earth to sun and measured as 1AU.   ‘Neo Reference ID’: This feature denotes the reference ID assigned to an asteroid.‘Name’: This feature denotes the name given to an asteroid.‘Absolute Magnitude’: This feature denotes the absolute magnitude of an asteroid. An asteroid’s absolute magnitude is the visual magnitude an observer would record if the asteroid were placed 1 Astronomical Unit (AU) away, and 1 AU from the Sun and at a zero phase angle.‘Est Dia in KM(min)’: This feature denotes the estimated diameter of the asteroid in kilometres (KM).‘Relative Velocity km per sec’: This feature denotes the relative velocity of the asteroid in kilometre per second.‘Orbiting Body’: This feature denotes the planet around which the asteroid is revolving.‘Eccentricity’: This feature denotes the value of eccentricity of the asteroid’s orbit. Just like many other bodies in the solar system, the realms made by asteroids are not perfect circles, but ellipses. The axis marked eccentricity is a measure of how far from circular each orbit is: the smaller the eccentricity number, the more circular the realm.                ‘Hazardous’: This feature denotes whether the asteroid is hazardous or not.     1. VISUALIZATION:EDA<jupyter_code>#Importing libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
#Importing the dataset
dataset=pd.read_csv("nasa.csv",encoding='latin-1')
dataset
#Dropping the Redundant and outliner columns
dataset.drop( ['Close Approach Date'], axis = 1, inplace = True)

dataset.drop( ['Orbiting Body'], axis = 1, inplace = True)

dataset.drop( ['Orbit Determination Date'], axis = 1, inplace = True)

dataset.drop( ['Equinox'], axis = 1, inplace = True)

dataset.drop(dataset.iloc[:,[0,1,2,4,5,6,7,8,9,10,11,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]],axis=1, inplace = True)
dataset
#UNIVARATE SELECTION-Dividing the dataset into dependent and independant variables
X = dataset.iloc[:,:-1]
Y = dataset.iloc[:,-1]
X
Y
from sklearn.preprocessing import LabelEncoder
labelencoder_Y = LabelEncoder()
Y = labelencoder_Y.fit_transform(Y)
Y
#First five rows
dataset.head(5)
#Last five rows
dataset.tail()
# Let's count the Number of aestoroids which are hazardous and not hazardous
is_Hazardous = dataset[dataset['Hazardous']==1]
not_Hazardous=dataset[dataset['Hazardous']== 0]
dataset.Hazardous.value_counts()
# Counting some values
print('Total = ',len(dataset))
print('Number of aestoroids which are hazardous = ',len(is_Hazardous))
print('Percentage hazardous aestoroids = ', len(is_Hazardous)/len(dataset) * 100, "%")
print('not hazardous aesteroids =', len(not_Hazardous))
print('Percentage not hazardous aestoroids  = ', len(not_Hazardous)/len(dataset) * 100, "%")

# plot the scatterplot of 'Est Dia in KM(min)' versus 'Relative Velocity km per sec'
sns.scatterplot(dataset['Est Dia in KM(min)'],dataset['Relative Velocity km per sec'], alpha=0.8, marker=r'$\clubsuit$',hue = dataset['Hazardous'])

# plotting the boxplot to see the average 'Relative Velocity km per sec' of the aestoroids which were hazardous and not hazardous
sns.boxplot(dataset['Hazardous'],dataset['Relative Velocity km per sec'])
# plotting the boxplot to see the average 'Relative Velocity km per sec' of the aestoroids which were hazardous and not hazardous
sns.boxplot(dataset['Hazardous'],dataset['Miss Dist.(Astronomical)'])
#plotting the barplot and pie chart to see the average 'Est Dia in KM(min)' of the aestoroids which were hazardous and not hazardous

f,ax=plt.subplots(1,2,figsize=(18,8))
dataset['Hazardous'].value_counts().plot.pie(explode=[0.1,0.1],autopct='%1.1f%%',ax=ax[0],shadow=True)
ax[0].set_title('Hazardous Count')
ax[0].set_ylabel('Count')
sns.countplot(dataset.Hazardous)
ax[1].set_title('Hazardous Count')
plt.show()
# correlation matrix
corrmat = dataset.corr()
f, ax = plt.subplots()
sns.heatmap(corrmat, vmax = 1, square = True)
# plotting the pairplot to see the relation btw target and features, to remove outliners
sns.pairplot(dataset,hue='Hazardous')
plt.show()
# made joinplot as type of linear regression to see relationship and the value range btw 2 features
sns.jointplot(x='Est Dia in KM(min)',y='Miss Dist.(Astronomical)',data=dataset,kind='reg')
sns.jointplot(x='Est Dia in KM(min)',y='Relative Velocity km per sec',data=dataset,kind='reg')
sns.jointplot(x='Relative Velocity km per sec',y='Miss Dist.(Astronomical)',data=dataset,kind='reg')
# histgram and kde as standard gaussian graph normalizing the value from 0-1 
sns.distplot(dataset['Relative Velocity km per sec'],bins=20)
plt.xlabel("Relative Velocity km per sec")
plt.ylabel("Total count")
plt.title("Histogram")
plt.show()
sns.distplot(dataset['Est Dia in KM(min)'],bins=20)
plt.xlabel("Est Dia in KM(min)")
plt.ylabel("Total count")
plt.title("Histogram")
plt.show()


sns.distplot(dataset['Miss Dist.(Astronomical)'],bins=20)
plt.xlabel("Miss Dist.(Astronomical)")
plt.ylabel("Total count")
plt.title("Histogram")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10649435628987404, 'fraction_numerical': 0.019139538688041878, 'mean_word_length': 6.209905660377358, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '522781', 'license': 'Apache-2.0', 'n_tokens_mistral': 2082, 'n_tokens_neox': 1921, 'n_words': 670, 'path': 'EDA.ipynb', 'repo_name': 'akhil-2907/data-science-project', 'size': '6113'}