2 Assignment: Object Oriented Programming Submit Assignment · Due Friday by 11:59p · Points 80 · Submitting a text entry box or a file upload · This assignment is the fourth part a a project where you...

its a coding assignment so no paper needed


2 Assignment: Object Oriented Programming Submit Assignment · Due Friday by 11:59p · Points 80 · Submitting a text entry box or a file upload · This assignment is the fourth part a a project where you use earthquake data from http://earthquake.usgs.gov/ to understand earthquake trends. · In this part of the assignment you will revise your previous stats.py solution to use object oriented programming concepts AND to us a Pandas dataframe to compute basic statistics. · You will create at least two related classes (e.g. Earthquakes and Position) that will be initialized using data from the index..sqlite database. · You will read Earthquakes from the database but instead of putting them into individual lists for each type of date, you will create a list of Earthquake objects. · You will use the list of Earthquakes to populate a Panda's dataframe and then use the dataframe to compute basic statistics for the entire population of earthquakes, as well as for subsets of the data that are created by applying a filter to the dataframe. · You should put the two related classes in a file Earthquake.py and use import to include it in the python program where you read earthquakes from the database, create a list of earthquake objects, create a pandas dataframe and compute statistics. · You will be developing Earthquake.py and earthquake_stats.py for this part of the assignment. · Earthquake.py Write an Earthquake class that demonstrates the following aspects of OOP in Python: 1. Create a basic class that can hold all relevant earthquake data saved in index.sqlite. 2. Appropriately create a constructor to set all data values . 3. Create a regular class method that returns all or part of the Earthquake data as a dictionary object. 4. Override the __str__ method to print a reasonable string representation of an Earthquake. 5. Use the @property decorator to make at least one property in your Earthquake class private. 6. Use the @???.setter method to validate the private property in some way (e.g. check if its numeric, change it's data type, change it's length...) before setting its value. Write a second class called Point, Position or Time to store one or more pieces of earthquake data.This class can be included in the Earthquake.py file. · The class could store latitude & longitude OR latitude and longitude and depth OR timestamp · You should use this class in the Earthquake class instead of storing the vales as primitive data types · This class should include an __init__ method and a __str__ method.  If you create class to stor time, the __str__ method should return a formatted string, not a timestamp. You may use the Author and Article classes presented in lecture as a starting point for these classes. Earthquake_stats.py Write an Earthquake_stats class that uses the Earthquake object AND a Pandas dataframe to process earthquake data and display basic statistics. · You should import the Earthquake module to use in this application. · You will read Earthquakes from the database, just like in stats.py,  but instead of putting them into individual lists for each type of date, you will create a list of Earthquake objects. · You will  list of earthquake objects to a Panda's Dataframe. · See https://stackoverflow.com/questions/47623014/converting-a-list-of-objects-to-a-pandas-dataframe (Links to an external site.) for an example of how to use a custom method to turn you object into a dictionary AND use list comprehension to create a list of Earthquake dictionaries to create your DataFrame. · Display either the first 5 or last 5 earthquakes in the dataframe to the screen. · Use the dataframe to compute basic statistics for the entire population of earthquakes · Compute the same basic statistics for earthquakes filtered on Region. Computer a separate set of statistics for two different regions that have at least 200 earthquakes in your sample. · Compute the same basic statistics for all earthquakes filtered by either felt, tsunami or depth e.g felt > 0, tsunami > 0, depth < 50="" or=""><100. you="" can="" use stats.py,="" from="" the="" last="" assignment,="" and pandas:="" inspecting="" &="" analyzing="" data as="" starting="" points="" for="" this="" part="" of="" the="" assignment.="" submitting="" your="" work="" please="" upload="" your="" submission:="" ·="" a="" screen="" shot/.ipynb="" files="" of="" the="" earthquake_stats.py="" program="" tthat="" shows="" the="" basic="" statistics="" on="" the="" messages="" you="" have="" retrieved/analyzed.="" ·="" a="" zip="" file="" containing="" all="" of="" the="" .py/.ipynb="" and="" .sqlite="" files="" you="" created/used="" as="" a="" part="" of="" the="" assignment.="" ·="" ·="" ·="" ·="" some="" sample="" code="" from="" previous="" assignment="" (just="" to="" give="" you="" an="" ideas="" below="" this="" line="" there="" is="" nothing="" related="" to="" requirement="" of="" current="" assignment)="" ·="" ·="" ·="" assignment:="" data="" analysis="" and="" visualization="" re-submit="" assignment="" ·="" due nov="" 18 by 11:59pm=""  ="" ·="" points 80=""  ="" ·="" submitting a="" text="" entry="" box="" or="" a="" file="" upload="" ·="" this="" assignment="" is="" the="" third="" part="" a="" a="" project="" where="" you="" use="" earthquake="" data="" from="" http://earthquake.usgs.gov/="" to="" understand="" earthquake="" trends.="" ·="" in="" this="" part="" of="" the="" assignment="" you="" will="" run ="" an="" analysis="" to="" calculate="" some="" basic="" statistics="" about="" the="" data.="" ·="" you="" will="" then="" create="" at="" least="" three="" different="" types="" of="" visualizations="" of="" the="" earthquake="" data="" you="" have="" retrieved="" and="" processed="" and="" save="" some="" plots.="" for="" example:="" ·="" either="" a="" word="" cloud="" to="" or="" a="" bar="" chart="" to="" visualize="" the="" frequency="" distribution="" by="" region.="" ·="" a="" histogram="" of="" the="" magnitudes="" of="" "felt"="" earthquakes="" in="" the="" data="" set.="" ·="" a="" scatter="" plot="" to="" show="" how="" the="" data="" is="" changing="" over="" time.="" ·="" you="" will="" be="" developing stats.py and plots.py for="" this="" part="" of="" the="" assignment.="" project="" structure="" stats.py="" the="" first,="" simplest="" data="" analysis="" is="" to="" do="" a="" simple="" analysis="" of="" the="" data="" to="" answer="" the="" following="" questions:="" ·="" how="" many="" earthquakes="" are="" in="" the="" data="" set?="" ·="" what="" "place"="" has="" the="" most="" earthquakes?="" ·="" what="" "region"="" has="" the="" most="" earthquakes?="" ·="" what="" was="" the="" "biggest"="" earthquake="" int="" he="" data="" set?="" ·="" what="" is="" the="" mean="" earthquake="" magnitude="" in="" the="" data="" set?="" ·="" what="" is="" the="" median="" earthquake="" magnitude="" in="" the="" data="" set?="" ·="" what="" is="" the="" standard="" deviation="" of="" the="" earthquake="" magnitudes="" in="" the="" data="" set?="" ·="" what="" are="" the="" same="" basic="" statistics for="" earthquakes="" filtered="" by="" either="" felt,="" tsunami="" or="" depth?="" e.g="" felt=""> 0, tsunami > 0, depth < 50="" or=""><100. #="" -*-="" coding:="" utf-8="" -*-="" """="" python="" program="" to="" calculate="" basic="" statistics="" about="" a="" sample="" of="" earthquakes="" created="" on="" sat="" dec="" 15="" 10:00:02="" 2018="" @author:="" dawng="" """="" #="" add="" necessary="" import="" statements="" _________________="" _________________="" #="" add="" input="" validation="" to="" make="" sure="" an="" integer="" between="" 1="" and="" 20="" is="" provided="" #="" program="" should="" repeat="" request="" for="" a="" number="" or="" exit="" if="" invalid="" input="" is="" provided="" howmany="int(input("How" many="" earthquake="" locations="" to="" show?="" "))="" #="" connect="" to="" the="" output="" database="" and="" name="" it="" index.sqlite="" conn="______________________" #="" forces="" database="" to="" return="" strings="" for="" text="" attributes="" conn.text_factory="str" #="" get="" the="" cursor="" for="" the="" connection="" cur="___________________" #="" run="" select="" query="" on="" database="" to="" get="" data="" for="" statistics="" ________________________________________________________="" #="" set="" up="" variables="" to="" hold="" database="" data="" #="" will="" be="" counting="" earthquakes="" by="" place/region="" #="" will="" just="" be="" storing="" data="" about="" magnitude,="" felt="" and="" tsunami="" placecounts="dict()" regioncounts="dict()" mag="[]" felt="[]" tsunami="[]" depth="[]" for="" quake="" in="" cur="" :="" #="" get="" data="" from="" cursor="" and="" add="" to="" lists="" or="" dictionary="" #="" dictionaries="" will="" hold="" counts,="" lists="" will="" append="" data="" _____________________________="" _____________________________="" _____________________________="" _____________________________="" _____________________________="" #="" print="" out="" top="" earthquake="" places="" print('')="" print('top',howmany,'earthquake="" places')="" x="sorted(placecounts," key="placecounts.get," reverse="True)" for="" k="" in="" x[:howmany]:="" print(k,="" placecounts[k])="" if="" placecounts[k]="">< 10="" :="" break="" #="" print="" out="" top="" earthquake="" regions="" print('\ntop',howmany,'earthquake="" regions')="" _____________________________________________________="" ____________________="" _________________________________="" _________________________________="" print("\nbasic="" statistics")="" #="" print="" out="" basic="" statistics="" like="" number="" of="" earthquakes,="" mean="" magnitude,="" median,="" standard="" deviation="" etc.="" _____________________________________________________="" _____________________________________________________="" _____________________________________________________="" _____________________________________________________="" #="" convert="" the="" "felt/tsunami/depth"="" list="" to="" a="" numpy="" array="" npfilter="_______________________" #="" create="" a="" numpy="" array="" of="" booleans="" where="" felt="" or="" tsunami"=""> 0 or depth < 50 filterb = ________________________ # create a numpy array of magnitudes for all of the filtered earthquakes magf = _____________________________ # print out basic statistics like number of felt earthquakes, mean felt earthquake ... _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ plots.py · plots.py will be very similar to stats.py. · you would start with stats.py, save as plots.py · add an import for pyplot · get data from the database and add it to dictionaries and/or lists · create at least three different types of plots using the ideas below: · create a dictionary for earthquake regions but instead of printing out the regions, plot the top "howmany" regions, show them on a bar chart and/or a wordcloud · create a histogram and/or scatter plot for "felt" earthquake magnitudes. · create a histogram and/or scatter plot for all earthquake magnitudes · create a histogram and/or scatter plot for "tsunami waning" earthquake magnitudes. · create a histogram and/or scatter plot for felt earthquake depths. · create any of the above histograms and/or scatter plots for a specific region (especially useful if you are tracking earthquake activity around a specific major quake) · create a title, xlabel and ylabel for each of your plots (except for a wordcloud) · call savefig for each of your plots and save as a png.   submitting your work please upload your submission: · submit either: · a screen shot of you running the stats.py program to compute basic histogram data and statistics on the messages you have retrieved. · a saved .png file each of the plots you made with plots.py. · or · jupyter notebook .ipynb file(s) that includes the code and shows the output statistics and plots. · and a zip file containing all of the .py, .ipynb and .sqlite files you created/used as a part of the assignment. · rubric data visualization data visualization criteria ratings pts this criterion is linked to a learning outcomean updated stats.py file that connects to the database, includes an appropriate select query and extracts data from the query. 8.0 pts full marks 4.0 pts mostly correct but missing some required code or formatting. 0.0 pts no marks 8.0 pts this criterion is linked to a learning outcomethe updated stats.py file that displays the top regions and places where earthquakes have occurred. 7.0 pts full marks 4.0 pts missing some important program elements. 0.0 pts no marks 7.0 pts this criterion is linked to a learning outcomethe updated stats.py file that computes statistics for all earthquakes 10.0 pts full marks 6.0 pts runs but missing some important program elements. 0.0 pts no marks 10.0 pts this criterion is linked to a learning outcomethe updated stats.py file that computes statistics for earthquakes filtered by either felt, tsunami or depth 5.0 pts full marks 3.0 pts second set of statistics calculated but not filtered correctly 0.0 pts no marks 5.0 pts this criterion is linked to a learning outcomeplots 50="" filterb="________________________" #="" create="" a="" numpy="" array="" of="" magnitudes="" for="" all="" of="" the="" filtered="" earthquakes="" magf="_____________________________" #="" print="" out="" basic="" statistics="" like="" number="" of="" felt="" earthquakes,="" mean="" felt="" earthquake="" ...="" _____________________________________________________="" _____________________________________________________="" _____________________________________________________="" _____________________________________________________="" plots.py="" ·="" plots.py will="" be="" very="" similar="" to stats.py.="" ·="" you="" would="" start="" with stats.py,="" save="" as plots.py="" ·="" add="" an="" import="" for="" pyplot="" ·="" get="" data="" from="" the="" database="" and="" add="" it="" to="" dictionaries="" and/or="" lists="" ·="" create="" at="" least="" three="" different="" types="" of="" plots="" using="" the="" ideas="" below:="" ·="" create="" a="" dictionary="" for="" earthquake="" regions="" but="" instead="" of="" printing="" out="" the="" regions,="" plot="" the="" top="" "howmany"="" regions,="" show="" them="" on="" a="" bar="" chart="" and/or="" a="" wordcloud="" ·="" create="" a="" histogram="" and/or="" scatter="" plot="" for="" "felt"="" earthquake="" magnitudes.="" ·="" create="" a="" histogram="" and/or="" scatter="" plot="" for="" all="" earthquake="" magnitudes="" ·="" create="" a="" histogram="" and/or="" scatter="" plot="" for="" "tsunami="" waning"="" earthquake="" magnitudes.="" ·="" create="" a="" histogram="" and/or="" scatter="" plot="" for="" felt="" earthquake="" depths.="" ·="" create="" any="" of="" the="" above="" histograms="" and/or="" scatter="" plots="" for="" a="" specific="" region="" (especially="" useful="" if="" you="" are="" tracking="" earthquake="" activity="" around="" a="" specific="" major="" quake)="" ·="" create="" a="" title,="" xlabel="" and="" ylabel="" for="" each="" of="" your="" plots="" (except="" for="" a="" wordcloud)="" ·="" call="" savefig="" for="" each="" of="" your="" plots="" and="" save="" as="" a="" png.=""  ="" submitting="" your="" work="" please="" upload="" your="" submission:="" ·="" submit="" either:="" ·="" a="" screen="" shot="" of="" you="" running="" the="" stats.py="" program="" to="" compute="" basic="" histogram="" data="" and="" statistics="" on="" the="" messages="" you="" have="" retrieved.="" ·="" a="" saved="" .png="" file="" each="" of="" the="" plots="" you="" made="" with plots.py.="" ·="" or="" ·="" jupyter="" notebook="" .ipynb="" file(s)="" that="" includes="" the="" code="" and="" shows="" the="" output="" statistics="" and="" plots.="" ·="" and="" a="" zip="" file="" containing="" all="" of="" the="" .py,="" .ipynb="" and="" .sqlite="" files="" you="" created/used="" as="" a="" part="" of="" the="" assignment.="" ·="" rubric="" data="" visualization="" data="" visualization="" criteria="" ratings="" pts="" this="" criterion="" is="" linked="" to="" a="" learning="" outcomean="" updated="" stats.py="" file="" that="" connects="" to="" the="" database,="" includes="" an="" appropriate="" select="" query="" and="" extracts="" data="" from="" the="" query.="" 8.0 pts="" full="" marks="" 4.0 pts="" mostly="" correct="" but="" missing="" some="" required="" code="" or="" formatting.="" 0.0 pts="" no="" marks="" 8.0 pts="" this="" criterion="" is="" linked="" to="" a="" learning="" outcomethe="" updated="" stats.py="" file="" that="" displays="" the="" top="" regions="" and="" places="" where="" earthquakes="" have="" occurred.="" 7.0 pts="" full="" marks="" 4.0 pts="" missing="" some="" important="" program="" elements.="" 0.0 pts="" no="" marks="" 7.0 pts="" this="" criterion="" is="" linked="" to="" a="" learning="" outcomethe="" updated="" stats.py="" file="" that="" computes="" statistics="" for="" all="" earthquakes="" 10.0 pts="" full="" marks="" 6.0 pts="" runs="" but="" missing="" some="" important="" program="" elements.="" 0.0 pts="" no="" marks="" 10.0 pts="" this="" criterion="" is="" linked="" to="" a="" learning="" outcomethe="" updated="" stats.py="" file="" that="" computes="" statistics="" for="" earthquakes="" filtered="" by="" either="" felt,="" tsunami="" or="" depth="" 5.0 pts="" full="" marks="" 3.0 pts="" second="" set="" of="" statistics="" calculated="" but="" not="" filtered="" correctly="" 0.0 pts="" no="" marks="" 5.0 pts="" this="" criterion="" is="" linked="" to="" a="" learning="">
Dec 02, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here