Final Project I (Final) (1)
Final Project I (Final) (1)
Introduction:
Meteor showers are celestial events that occur when Earth passes through
the debris left by comets or asteroids. These events can be spectacular and are
often a highlight for amateur astronomers and stargazers. However, the ability
to predict the visibility of these meteor showers depends on various factors,
including the paths of comets, atmospheric conditions, and light pollution. The
Meteor Shower Prediction Projection aims to develop a predictive system that
utilizes historical data to forecast the visibility of meteor showers from specific
locations on Earth.
In this project, we will use many tool and technique, data science and
machine learning as given below:
Use Python, Pandas, and Visual Studio Code to understand meteor
showers.
Use machine learning to cleanse and impute missing data from datasets.
Discover how to identify bimodal data across human and make
prediction of meteors.
Explore the Code Tour extension in Visual Studio Code for code
writing guidance.
2. OBJECTIVES:
1|data science
3. PREVIOUS WORK:
3|data science
5.3 Import data:
Code:
import numpy as np
import pandas as pd
Output:
Code:
meteor_showers.head()
Output:
4|data science
Code:
meteor_showers.info()
Output:
Code:
moon_phases.head()
Output:
5|data science
Code:
moon_phases.info()
Output:
Code:
constellations.head()
Output:
6|data science
Code:
constellations.info()
Output:
Code:
cities.head()
Output:
7|data science
Code:
cities.info()
Output:
We can see from the calls to head () that a lot of information is written in
words (strings) instead of numbers (integers). Some data makes sense as
strings, like city names or meteor shower names. But other data makes more
sense as integers, like months or Moon phases.
8|data science
Code:
months = {'january':1, 'february':2, 'march':3, 'april':4,
'may':5,'june':6, 'july':7, 'august':8, 'september':9,
'october':10, 'november':11, 'december':12}
meteor_showers.bestmonth =
meteor_showers.bestmonth.map(months)
meteor_showers.startmonth =
meteor_showers.startmonth.map(months)
meteor_showers.endmonth =
meteor_showers.endmonth.map(months)
moon_phases.month = moon_phases.month.map(months)
constellations.bestmonth =
constellations.bestmonth.map(months)
Verify your changes by adding calls to head() and info() to each of the
three DataFrames that you modified. For example:
Code:
meteor_showers.head()
Output:
Code:
meteor_showers.info()
Output:
9|data science
Before continue, convert months and days in
the meteor_showers DataFrame to a type called date time, which tracks dates.
Create two new columns: start date and end date. These columns will
contain a month and day in 2020:
Code:
meteor_showers['startdate'] =
pd.to_datetime(2020*10000+meteor_showers.startmonth*100+meteo
r_showers.startday,format='%Y%m%d')
meteor_showers['enddate'] =
pd.to_datetime(2020*10000+meteor_showers.endmonth*100+meteor_
showers.endday,format='%Y%m%d')
moon_phases['date'] =
pd.to_datetime(2020*10000+moon_phases.month*100+moon_phases.d
ay,format='%Y%m%d')
hemispheres = {'northern':0, 'southern':1, 'northern,
southern':3}
meteor_showers.hemisphere =
meteor_showers.hemisphere.map(hemispheres)
constellations.hemisphere =
constellations.hemisphere.map(hemispheres)
Moon_phase.head()
Output:
10 | d a t a s c i e n c e
Code:
check = moon_phases.groupby('moonphase')['moonphase'].count()
check
Output:
Finally, convert Moon phases to numbers that represent the percentage of the
Moon that's visible. This time, add a new column to represent the data:
Code:
phases = {'new moon':0,'third quarter':0.5, 'first
quarter':0.5,'full moon':1.0}
moon_phases['percentage'] =
moon_phases.moonphase.map(phases)
moon_phases.head()
Output:
11 | d a t a s c i e n c e
5.6 Remove unnecessary data:
Some of the data from these .csv files isn't useful. You can delete the
following data:
Code:
meteor_showers = meteor_showers.drop(['startmonth', 'startday',
'endmonth', 'endday', 'hemisphere'], axis=1)
moon_phases =
moon_phases.drop(['month','day','moonphase','specialevent'],
axis=1)
Output:
12 | d a t a s c i e n c e
5.7 Missing data:
Code:
lastPhase = 0
moon_phases.info()
Output:
13 | d a t a s c i e n c e
5.9 Write the prediction function:
This module introduces a simplified way to examine data. Without using a lot
of predictions, our method is a lot like a complex lookup table. You can later
expand on the model with data like weather to make it more like a classical
machine learning model.
The four data sets are:
14 | d a t a s c i e n c e
Code & Output:
Code:
def predict_best_meteor_shower_viewing(city):
def predict_best_meteor_shower_viewing(city):
predict_best_meteor_shower_viewing(city):
latitude = cities.loc[cities['city'] == city,
'latitude'].iloc[0]
return latitude
constellation_list =
constellations.loc[(constellations['latitudestart'] >=
latitude) & (constellations['latitudeend'] <= latitude),
'constellation'].tolist()
return constellation_list
print(predict_best_meteor_shower_viewing('Abu Dhabi'))
Output:
Unfortunately, San Diego isn't available for a
prediction at this time.
16 | d a t a s c i e n c e
5.11 Find the optimal date based on Moon phases:
Finally, we can find the minimum value of the Moon phase (the least
amount of light shining from the Moon). For this predictive function,
we just grab the first date
Code:
best_moon_date=moon_phases_list.loc[moon_phases_list['percenta
ge'].idxmin()]['date']
meteor_shower_string += meteor_shower + " is best seen if you look
towards the " + constellation + " constellation on " +
best_moon_date.to_pydatetime().strftime("%B %d, %Y") + ".\n"
One tricky part in this code is where we convert the date to a pydatetime and
then convert it to a string by using strftime. If we try to omit this part, we'll get
an error.
meteor_shower_string = ""
return meteor_shower_string
if not constellation_list:
return meteor_shower_string
meteor_shower_string = "In " + city + " you can see the following meteor
showers:\n"
17 | d a t a s c i e n c e
meteor_shower = meteor_showers.loc[meteor_showers['radiant'] ==
constellation, 'name'].iloc[0]
meteor_shower_startdate = meteor_showers.loc[meteor_showers['radiant']
== constellation, 'startdate'].iloc[0]
meteor_shower_enddate = meteor_showers.loc[meteor_showers['radiant']
== constellation, 'enddate'].iloc[0]
best_moon_date =
moon_phases_list.loc[moon_phases_list['percentage'].idxmin()]['date']
print(predict_best_meteor_shower_viewing('new delhi'))
Output:
Code:
moon_phase.describe()
18 | d a t a s c i e n c e
Output:
CONCLUSION:
The Meteor Shower Prediction Project aims to bridge the gap between
complex astronomical data and everyday stargazers. By leveraging historical
data, machine learning, and user engagement, this project seeks to enhance the
experience of observing meteor showers and foster a greater appreciation for
celestial events. The ongoing work is poised to make significant contributions
to the field of astronomy, making it more accessible to the general public.
19 | d a t a s c i e n c e
DESCRIPTION:
Meteor showers are celestial events that occur when Earth passes through
debris trails left by comets or asteroids. These stunning displays are a favorite
among astronomers and stargazers. However, predicting their visibility
depends on several factors, such as the paths of comets, atmospheric
conditions, and local light pollution.
The Meteor Shower Prediction Project aims to create a system that uses
historical data and advanced techniques to forecast meteor shower visibility
from specific locations. This project integrates data science and machine
learning tools to enhance prediction accuracy. Key objectives include:
20 | d a t a s c i e n c e
BIBLIOGRAPHY:
21 | d a t a s c i e n c e