General rules This exam should be in class and proctored; please come to our regular classroom...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
General rules This exam should be in class and proctored; please come to our regular classroom and bring your laptop. the submission by students who did not show up for the exam will not be graded. The exam will be on this .ipynb file. When you finish all the questions, please download this .ipynb file and turn it in to Canvas. You can use textbooks, lecture notes, your personal notes, and your own code as references during the exam. These are the only resources you are allowed to use. This exam is not an open-internet exam. Searching on the internet (like Google) is now allowed. For some questions, the instructor provided his output as a hint. Your goal is to provide the correct answers instead of reproducing what the instructor did with his solutions. Some questions may have many possible solutions. If you need to create extra cells to answer a question, feel free to do so, but make sure the new cells created are under the correct question. The grading will be done by executing your code from top to bottom. In [2]: import numpy as np import pandas as pd import matplotlib.pyplot as plt CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [2]: In [4]: 1.1-Py View 1.2-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a few seconds ago (unsaved changes) Widgets Help Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 1.3-Fu Cell Run 1.3-Fu Kernel 1.4-Sli C Markdown import numpy as np import pandas as pd import matplotlib.pyplot as plt 1.5-Us 1.6-Ma [ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.] 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < 1. Create a numpy array from 1 to 15 (both inclusive), and make the numpy array as an array of float numbers. Print the numpy array you have created. | Python 3 (ipykernel) O 2. arange() or linspace() Create a 1-D numpy array of the integer values 2,5,8,11,14,17,20,23. You have to use either arange() or linspace() provided in numpy. Print the numpy array you have created. You should not use iteration in this question. Q Search Logout ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py Farl View 1.2-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a few seconds ago (unsaved changes) Kernel Widgets Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 1.3-Fu Cell 1.3-Fu Run 1.4-Sli Markdown Help In [5]: Out [5]: array([ 2, 5, 8, 11, 14, 17, 20, 23]) Q Search 1.5-Us DO 1.6-Ma 2.1-Nu 3. Line plot ** ** Plot the line of function x 3-2*x+6 and x 2 + 3 * x + 26 as two lines in one plot. You can create x values from -1 to 15 (with no less than 100 values between). Add legends for those two lines. 2.2-Nu 110% Not Trusted 2 > 2. arange() or linspace() Create a 1-D numpy array of the integer values 2,5,8,11,14,17,20,23. You have to use either arange() or linspace() provided in numpy. Print the numpy array you have created. You should not use iteration in this question. + < Python 3 (ipykernel) O Logout ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Mid X + 1.1-Py Edit View In [25]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a few seconds ago (unsaved changes) Widgets Help 3500 3000 2500 2000 1500 1000 1.2-Py 500 0 Cell 0 1.3-Fu Run 2 Kernel x**3-2*x+6 - x** 2+ 3*x + 26 1.3-Fu 4 C Markdown 6 -80 1.4-Sli 10 Q Search 12 DO 1.5-Us 14 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < 4. 2D array Create a 2-D array m that has 15 random values following normal distribution, then force the values to form a 3*5 matrix. You Logout Python 3 (ipykernel) O ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit In [6]: 1.1-Py YouTube View 1.2-Py localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert 1.3-Fu Cell m = m Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Run 1.3-Fu Kernel Widgets Help 1.4-Sli C Markdown 2 > 1.5-Us np.random.seed (17) # random see, do not change this line. POL 1.6-Ma Q Search 2.1-Nu Out [6]: array([[ 0.27626589, -1.85462808, 0.62390111, 1.14531129, 1.03719047], [ 1.88663893, -0.11169829, -0.36210134, 0.14867505, -0.43778315], [ 2.171257 1.15231025, -1.81881234, -0.13804934, 0.53983961]]) 2.2-Nu 110% In [9]: N Out [9]: array([-1.85462808, 0.62390111, 1.14531129, 1.03719047, 1.88663893, 1.15231025, -1.81881234, 0.53983961]) 2.171257 Not Trusted 4. 2D array Create a 2-D array m that has 15 random values following normal distribution, then force the values to form a 3*5 matrix. You need to use the random value generating method in numpy for this part. Find all the values that are either smaller than -0.5 or greater than 0.5 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit 1.1-Py YouTube 1.2-Py View localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 1.3-Fu Insert Cell Run 1.3-Fu Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Kernel 1.4-Sli Widgets Help C Markdown 1.5-Us POL 1.6-Ma plot the data using a visualization type that you can justify have a proper title for the plot use millions as the unit for the axis that you show the subscribers show the names of mukbangers as part of your plot Q Search 2.1-Nu 2.2-Nu 110% ENG SUB) ASMR MUKBANG TRUFFLE OIL BLACK BEA... 13 Not Trusted 2 > + 5. Visualizations Below are a list of top mukbangers and a list of their numbers of subscribers. The mukbangers' names and the numbers of subscribers are paired; namely, the first muckbanger, "Jane ASMR" has 15532281 subscribers. Please choose a proper visualization type to show this data. Your visualization should - < Python 3 (ipykernel) O Hint - to turn the number of subscribers into millions, turn subscribers array into a numpy array first, then divide the values by 1 million. Dr. Song decided not to provide his visualizations for this question - any reasonable choice of plot type will be accepted. Logout (background information - Mukbang is Korean for "Eating Broadcast". It is a live-streamed eating show where the host binge eats. It became very popular in Korea around 2010.) Watch later Share ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit 1.1-Py YouTube 1.2-Py View localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Cell 1.3-Fu Run 1.3-Fu Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Pause (k) 1.4-Sli Kernel Widgets Help C Markdown 1.5-Us 2 Q Search 1.6-Ma ENG SUB) ASMR MUKBANG TRUFFLE OIL BLACK BEA... 13 2.1-Nu 22 2.2-Nu 110% Not Trusted Watch later 2 > + < Share | Python 3 (ipykernel) O Please be aware - mukbangers promote unhealthy eating habits. In this question, we use mukbangers' subscribers dataset, but please consult with your healthcare provider if you consider adopting their eating habits, or if you want to be a mukbanger. Logout ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Mid X Edit In [10]: 1.1-Py View 1.2-Py Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Widgets Help 1.3-Fu Cell Run 13340783 > 10966352 8389367 2 8284601 > 7187394 > 7104523 2 7001452 2 6210593 > 5251078 > 5019893] Kernel 1.3-Fu mukbangers = ['Jane ASMR', 'ZACH CHOI ASMR', 'Hongyu ASMR', 'Hamzy', 'SULGI', 'GONGSAM TABLE', C Markdown 'Ssoyoung', 'Eat wit Boki', 'SIO ASMR', 'DONA', 'tzuyang'] subscribers =[15532281, 1.4-Sli Q Search 1.5-Us 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit 1.1-Py YouTube 1.2-Py View 1.3-Fu localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Cell Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Kernel Widgets 1.3-Fu Number Published 7 5 1.4-Sli 2 Q Search Help 1.5-Us D 1.6-Ma 2.1-Nu 2.2-Nu 110% Run C Markdown 6. What is the problem with the visualizations below - a short answer question Below is a visualization Dr. Song saw last week from a research paper. The authors report the number of papers published on a research topic (auto-grading code quality for software engineering classes) in the past 10 years. Using the knowledge we have learned from CSC 322 so far, what is (are) the problem(s) with this visualization? Not Trusted 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py View 1.2-Py Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Widgets Help 1.3-Fu Cell Run Kernel C Markdown Number Published 7 5 1.3-Fu 2 1 0 1.4-Sli Q Search 1.5-Us DO 1.6-Ma 2.1-Nu 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 Year Published 2.2-Nu 110% Not Trusted 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py View 1.2-Py Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Widgets Help Cell Run add your answers here 1.3-Fu Pre-processing Steps 1.3-Fu Kernel add your answers here C Markdown Normalize tokens Convert to Source to Graph (AST, CFG or DDG) Build good set using unit tests 1.4-Sli Remove comments Q Search 1.5-Us POL 20 1. 1.6-Ma The second visualization is also from the same paper. It shows the percentages of data processing techniques used by the papers surveyed. Using the knowledge we have learned from CSC 322 so far, what are the problems with this visualization? 40 2.1-Nu 60 2.2-Nu 110% Not Trusted 2 > + 100 < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [14]: 1.1-Py View Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Widgets Help localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Out [14]: Insert 1.2-Py 0 1.3-Fu Cell id 12899 Kernel 1.3-Fu Run C Markdown Reading in a dataset for the next few questions In the next few question, we will load an AirBnB dataset for the city of Portland, Oregon. charming 1906 house Beautiful 1.4-Sli = portland_original pd.read_csv("data/Portland_Listing.csv") portland_original.head() #display the first 5 rows of this dataset suite, 49682 1.5-Us D Ali And David 1.6-Ma Q Search 2.1-Nu If you do not have this file yet, please download Portland_Listing.csv file in the data folder to the same directory as your current notebook (or any convenient path that you can load it in). The code below reads in this dataset as dataframe portland_original. In the rest of this notebook, please do not update this dataframe. The dataset has the column names built-in, so you don't have to specify the column names. NaN 2.2-Nu 110% Not Trusted 2 > name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price | Alberta Arts 2 bedroom + < Concordia 45.56401 -122.63472 Python 3 (ipykernel) O Logout Entire home/apt ENG IN 65 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Mid X Edit 1.1-Py View Out [14]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 0 Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Kernel Widgets Help Insert id 12899 1 16688 1.2-Py 2 25200 3 26203 Cell Run charming 1906 house suite, 49682 Beautiful condo in downtown Pearl, NW Portland Flamenco Dream :: 1.3-Fu mississippi ave. Bluebird @hip mississippi hip 104038 ave Markdown Lovely SW 1.3-Fu 64840 104038 name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price Alberta Arts 2 bedroom Ali And David Ashish 1.4-Sli Garden Garden Q Search 1.5-Us w NaN NaN NaN 1.6-Ma NaN 2.1-Nu 2.2-Nu 110% 2 > Concordia 45.56401 -122.63472 Not Trusted | Python 3 (ipykernel) O Pearl 45.52542 -122.68557 + Humboldt 45.55675 -122.67784 < Humboldt 45.55696 -122.67566 Entire home/apt Entire home/apt Private room Logout Private room ENG IN 65 275 65 65 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [15]: 1.1-Py View Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Kernel Widgets Out [15]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert 1.2-Py choices = choices 0 1 Cell Run 1.3-Fu id 12899 portland_original[_ 16688 CMarkdown 1.3-Fu name Alberta Arts 2 bedroom suite, charming 1906 house Beautiful condo in downtown Pearl, NW 1.4-Sli 7. Masking with dataframe (continue using the portland dataset) Dr. Song plans to travel to Portland, he wants to stay in a place that has the room_type as 'Entire home/apt', and he only plans to stay for 2 nights (so if an AirBnB requires minimum_nights higher than 2, it won't work for Dr. Song). Hint - there are at least 2000 options. 49682 64840 Help Q Search 1.5-Us Ali And David POL Ashish 1.6-Ma _] 2.1-Nu NaN 2.2-Nu NaN 110% host_id host_name neighbourhood_group neighbourhood latitude longitude room_ Not Trusted 2 > + < Python 3 (ipykernel) O Concordia 45.56401 -122.63472 Logout Pearl 45.52542 -122.68557 ENG IN E home E home 1:57 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py View 1.2-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (autosaved) localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert In [17]: Out [17]: Cell Run 1.3-Fu id 619 4684661 1.3-Fu Kernel 3612 32246990 Hint- there should be no more than 5 choices. Widgets C Markdown 3 bedroom, "pet friendly" town home in 1.4-Sli 5192007 Help Q Search 1.5-Us DO Kelly And Rich 8. Most expensive ones? (please use the portland_original dataframe.) The price column is the price of each AirBnB per night. Let's assume that Dr. Song wants a luxury trip. Please help Dr. Song find the expensive AirBnBs in Portland that have a price higher than 1500. 1.6-Ma 2.1-Nu NaN 2.2-Nu NaN 110% Not Trusted name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type Charming quiet bohemian 24223207 Catherine urban getaway! 2 > + < Python 3 (ipykernel) O Richmond 45.49982 -122.62814 Montavilla 45.50574 -122.57099 Logout Entire home/apt Entire home/apt ENG IN 1:57 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [18]: View 1.1-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (autosaved) Kernel Widgets Out [18]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb In [19]: a 1.2-Py Insert e Out [19]: a e Cell 1.3-Fu Alex Tom 1.3-Fu Sammy Josh Jen Flossie dtype: object Alex Sammy Jen Run 9. Slicing a pandas series The line below creates a panda series for six names, and the indexes used are from a from f. Provide two different ways to select Alex, Sammy, and Jen. 1.4-Sli CMarkdown Help Q Search 1.5-Us DO x = pd. Series (['Alex', 'Tom', 'Sammy', 'Josh', 'Jen', 'Flossie'], index=list('abcdef')) X 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < Python 3 (ipykernel) O Logout ENG IN 1:57 PM 2/20/2023 Xx ||| 1 CSC 3 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit View In [19]: Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 3 minutes ago (autosaved) Widgets Help 1.1-Py localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Out [19]: a e In [20]: 1.2-Py Out [20]: a e Insert Cell dtype: object Run Alex Sammy Jen dtype: object 1.3-Fu Alex Sammy Jen dtype: object 1.3-Fu Kernel 1.4-Sli C Markdown 1.5-Us DO Q Search # required - another solution 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted > + 10. data selection (please start from the portland_original dataframe. This dataframe should not be updated between question 6 to question 10.) < D Python 3 (ipykernel) O Logout ENG IN 1:58 PM 2/20/2023 Xx ||| 1 CSC 3 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit In [24]: 1.1-Py YouTube 1.2-Py View localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Cell 1.3-Fu Midterm1 - 322-2023 Last Checkpoint: 3 minutes ago (autosaved) Widgets Help Run 1.3-Fu portland_df = = portland_df Kernel 1.4-Sli C Markdown 1.5-Us DO Q Search 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted > + 10. data selection (please start from the portland_original dataframe. This dataframe should not be updated between question 6 to question 10.) Please follow the steps below - create a portland_df from portland_orginal by only selecting the column of 'id', 'name','price', 'last_review' and 'reviews_per_month'; do a fillna(0) and replace all the NaN values in your portland_df dataframe into 0. only keep the first 20 rows in your portland_df . Please note that this dataframe is using integer indexes. < D Hint- there are multiple ways to do this. You don't have to do the column selection and row selection in one line. Feel free to break this process into multiple lines or multiple cells. Python 3 (ipykernel) O Logout ENG IN 1:58 PM 2/20/2023 Xx ||| 1 I CSC 3 C Getting Started G Gmail 71F Partly sunny File Mid X Edit In [24]: 1.1-Py View Out [24]: Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 3 minutes ago (autosaved) Widgets Help localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert portland_df id portland_df 0 12899 1 16688 1.2-Py 2 25200 3 26203 4 29931 Cell 5 37676 6 39938 7 41601 8 42347 1.3-Fu Run = 1.3-Fu Kernel 1.4-Sli C Markdown 1.5-Us Q Search Alberta Arts 2 bedroom suite, charming 1906 house Beautiful condo in downtown Pearl, NW Portland Flamenco Dream :: hip mississippi ave. Bluebird @hip mississippi ave Lovely SW Victorian w/Bonus Room and Hot Tub Mt. Hood View in the Pearl District 125 Friendly Guesthouse / 10 Min to Airport & Down... 29 Grandpa's Bunkhouse-Backyard Studio 130 Portland is Accessible! 55 65 65 200 1.6-Ma name price last_review reviews_per_month 65 9/12/2019 275 9/8/2019 10/18/2018 8/19/2019 8/31/2019 8/31/2019 9/8/2019 9/15/2019 9/9/2019 2.1-Nu 2.2-Nu 110% Not Trusted 4.51 2.48 0.30 0.27 0.47 1.08 4.95 1.95 1.77 > + < D Logout Python 3 (ipykernel) O ENG IN 1:58 PM 2/20/2023 Xx ||| 1 General rules This exam should be in class and proctored; please come to our regular classroom and bring your laptop. the submission by students who did not show up for the exam will not be graded. The exam will be on this .ipynb file. When you finish all the questions, please download this .ipynb file and turn it in to Canvas. You can use textbooks, lecture notes, your personal notes, and your own code as references during the exam. These are the only resources you are allowed to use. This exam is not an open-internet exam. Searching on the internet (like Google) is now allowed. For some questions, the instructor provided his output as a hint. Your goal is to provide the correct answers instead of reproducing what the instructor did with his solutions. Some questions may have many possible solutions. If you need to create extra cells to answer a question, feel free to do so, but make sure the new cells created are under the correct question. The grading will be done by executing your code from top to bottom. In [2]: import numpy as np import pandas as pd import matplotlib.pyplot as plt CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [2]: In [4]: 1.1-Py View 1.2-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a few seconds ago (unsaved changes) Widgets Help Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 1.3-Fu Cell Run 1.3-Fu Kernel 1.4-Sli C Markdown import numpy as np import pandas as pd import matplotlib.pyplot as plt 1.5-Us 1.6-Ma [ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.] 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < 1. Create a numpy array from 1 to 15 (both inclusive), and make the numpy array as an array of float numbers. Print the numpy array you have created. | Python 3 (ipykernel) O 2. arange() or linspace() Create a 1-D numpy array of the integer values 2,5,8,11,14,17,20,23. You have to use either arange() or linspace() provided in numpy. Print the numpy array you have created. You should not use iteration in this question. Q Search Logout ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py Farl View 1.2-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a few seconds ago (unsaved changes) Kernel Widgets Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 1.3-Fu Cell 1.3-Fu Run 1.4-Sli Markdown Help In [5]: Out [5]: array([ 2, 5, 8, 11, 14, 17, 20, 23]) Q Search 1.5-Us DO 1.6-Ma 2.1-Nu 3. Line plot ** ** Plot the line of function x 3-2*x+6 and x 2 + 3 * x + 26 as two lines in one plot. You can create x values from -1 to 15 (with no less than 100 values between). Add legends for those two lines. 2.2-Nu 110% Not Trusted 2 > 2. arange() or linspace() Create a 1-D numpy array of the integer values 2,5,8,11,14,17,20,23. You have to use either arange() or linspace() provided in numpy. Print the numpy array you have created. You should not use iteration in this question. + < Python 3 (ipykernel) O Logout ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Mid X + 1.1-Py Edit View In [25]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a few seconds ago (unsaved changes) Widgets Help 3500 3000 2500 2000 1500 1000 1.2-Py 500 0 Cell 0 1.3-Fu Run 2 Kernel x**3-2*x+6 - x** 2+ 3*x + 26 1.3-Fu 4 C Markdown 6 -80 1.4-Sli 10 Q Search 12 DO 1.5-Us 14 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < 4. 2D array Create a 2-D array m that has 15 random values following normal distribution, then force the values to form a 3*5 matrix. You Logout Python 3 (ipykernel) O ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit In [6]: 1.1-Py YouTube View 1.2-Py localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert 1.3-Fu Cell m = m Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Run 1.3-Fu Kernel Widgets Help 1.4-Sli C Markdown 2 > 1.5-Us np.random.seed (17) # random see, do not change this line. POL 1.6-Ma Q Search 2.1-Nu Out [6]: array([[ 0.27626589, -1.85462808, 0.62390111, 1.14531129, 1.03719047], [ 1.88663893, -0.11169829, -0.36210134, 0.14867505, -0.43778315], [ 2.171257 1.15231025, -1.81881234, -0.13804934, 0.53983961]]) 2.2-Nu 110% In [9]: N Out [9]: array([-1.85462808, 0.62390111, 1.14531129, 1.03719047, 1.88663893, 1.15231025, -1.81881234, 0.53983961]) 2.171257 Not Trusted 4. 2D array Create a 2-D array m that has 15 random values following normal distribution, then force the values to form a 3*5 matrix. You need to use the random value generating method in numpy for this part. Find all the values that are either smaller than -0.5 or greater than 0.5 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:55 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit 1.1-Py YouTube 1.2-Py View localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 1.3-Fu Insert Cell Run 1.3-Fu Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Kernel 1.4-Sli Widgets Help C Markdown 1.5-Us POL 1.6-Ma plot the data using a visualization type that you can justify have a proper title for the plot use millions as the unit for the axis that you show the subscribers show the names of mukbangers as part of your plot Q Search 2.1-Nu 2.2-Nu 110% ENG SUB) ASMR MUKBANG TRUFFLE OIL BLACK BEA... 13 Not Trusted 2 > + 5. Visualizations Below are a list of top mukbangers and a list of their numbers of subscribers. The mukbangers' names and the numbers of subscribers are paired; namely, the first muckbanger, "Jane ASMR" has 15532281 subscribers. Please choose a proper visualization type to show this data. Your visualization should - < Python 3 (ipykernel) O Hint - to turn the number of subscribers into millions, turn subscribers array into a numpy array first, then divide the values by 1 million. Dr. Song decided not to provide his visualizations for this question - any reasonable choice of plot type will be accepted. Logout (background information - Mukbang is Korean for "Eating Broadcast". It is a live-streamed eating show where the host binge eats. It became very popular in Korea around 2010.) Watch later Share ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit 1.1-Py YouTube 1.2-Py View localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Cell 1.3-Fu Run 1.3-Fu Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Pause (k) 1.4-Sli Kernel Widgets Help C Markdown 1.5-Us 2 Q Search 1.6-Ma ENG SUB) ASMR MUKBANG TRUFFLE OIL BLACK BEA... 13 2.1-Nu 22 2.2-Nu 110% Not Trusted Watch later 2 > + < Share | Python 3 (ipykernel) O Please be aware - mukbangers promote unhealthy eating habits. In this question, we use mukbangers' subscribers dataset, but please consult with your healthcare provider if you consider adopting their eating habits, or if you want to be a mukbanger. Logout ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Mid X Edit In [10]: 1.1-Py View 1.2-Py Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Widgets Help 1.3-Fu Cell Run 13340783 > 10966352 8389367 2 8284601 > 7187394 > 7104523 2 7001452 2 6210593 > 5251078 > 5019893] Kernel 1.3-Fu mukbangers = ['Jane ASMR', 'ZACH CHOI ASMR', 'Hongyu ASMR', 'Hamzy', 'SULGI', 'GONGSAM TABLE', C Markdown 'Ssoyoung', 'Eat wit Boki', 'SIO ASMR', 'DONA', 'tzuyang'] subscribers =[15532281, 1.4-Sli Q Search 1.5-Us 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit 1.1-Py YouTube 1.2-Py View 1.3-Fu localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Cell Midterm1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Kernel Widgets 1.3-Fu Number Published 7 5 1.4-Sli 2 Q Search Help 1.5-Us D 1.6-Ma 2.1-Nu 2.2-Nu 110% Run C Markdown 6. What is the problem with the visualizations below - a short answer question Below is a visualization Dr. Song saw last week from a research paper. The authors report the number of papers published on a research topic (auto-grading code quality for software engineering classes) in the past 10 years. Using the knowledge we have learned from CSC 322 so far, what is (are) the problem(s) with this visualization? Not Trusted 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py View 1.2-Py Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: a minute ago (unsaved changes) Widgets Help 1.3-Fu Cell Run Kernel C Markdown Number Published 7 5 1.3-Fu 2 1 0 1.4-Sli Q Search 1.5-Us DO 1.6-Ma 2.1-Nu 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 Year Published 2.2-Nu 110% Not Trusted 2 > + < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py View 1.2-Py Insert localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Widgets Help Cell Run add your answers here 1.3-Fu Pre-processing Steps 1.3-Fu Kernel add your answers here C Markdown Normalize tokens Convert to Source to Graph (AST, CFG or DDG) Build good set using unit tests 1.4-Sli Remove comments Q Search 1.5-Us POL 20 1. 1.6-Ma The second visualization is also from the same paper. It shows the percentages of data processing techniques used by the papers surveyed. Using the knowledge we have learned from CSC 322 so far, what are the problems with this visualization? 40 2.1-Nu 60 2.2-Nu 110% Not Trusted 2 > + 100 < Logout Python 3 (ipykernel) O ENG IN 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [14]: 1.1-Py View Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Widgets Help localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Out [14]: Insert 1.2-Py 0 1.3-Fu Cell id 12899 Kernel 1.3-Fu Run C Markdown Reading in a dataset for the next few questions In the next few question, we will load an AirBnB dataset for the city of Portland, Oregon. charming 1906 house Beautiful 1.4-Sli = portland_original pd.read_csv("data/Portland_Listing.csv") portland_original.head() #display the first 5 rows of this dataset suite, 49682 1.5-Us D Ali And David 1.6-Ma Q Search 2.1-Nu If you do not have this file yet, please download Portland_Listing.csv file in the data folder to the same directory as your current notebook (or any convenient path that you can load it in). The code below reads in this dataset as dataframe portland_original. In the rest of this notebook, please do not update this dataframe. The dataset has the column names built-in, so you don't have to specify the column names. NaN 2.2-Nu 110% Not Trusted 2 > name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price | Alberta Arts 2 bedroom + < Concordia 45.56401 -122.63472 Python 3 (ipykernel) O Logout Entire home/apt ENG IN 65 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File Mid X Edit 1.1-Py View Out [14]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb 0 Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Kernel Widgets Help Insert id 12899 1 16688 1.2-Py 2 25200 3 26203 Cell Run charming 1906 house suite, 49682 Beautiful condo in downtown Pearl, NW Portland Flamenco Dream :: 1.3-Fu mississippi ave. Bluebird @hip mississippi hip 104038 ave Markdown Lovely SW 1.3-Fu 64840 104038 name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price Alberta Arts 2 bedroom Ali And David Ashish 1.4-Sli Garden Garden Q Search 1.5-Us w NaN NaN NaN 1.6-Ma NaN 2.1-Nu 2.2-Nu 110% 2 > Concordia 45.56401 -122.63472 Not Trusted | Python 3 (ipykernel) O Pearl 45.52542 -122.68557 + Humboldt 45.55675 -122.67784 < Humboldt 45.55696 -122.67566 Entire home/apt Entire home/apt Private room Logout Private room ENG IN 65 275 65 65 1:56 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [15]: 1.1-Py View Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (unsaved changes) Kernel Widgets Out [15]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert 1.2-Py choices = choices 0 1 Cell Run 1.3-Fu id 12899 portland_original[_ 16688 CMarkdown 1.3-Fu name Alberta Arts 2 bedroom suite, charming 1906 house Beautiful condo in downtown Pearl, NW 1.4-Sli 7. Masking with dataframe (continue using the portland dataset) Dr. Song plans to travel to Portland, he wants to stay in a place that has the room_type as 'Entire home/apt', and he only plans to stay for 2 nights (so if an AirBnB requires minimum_nights higher than 2, it won't work for Dr. Song). Hint - there are at least 2000 options. 49682 64840 Help Q Search 1.5-Us Ali And David POL Ashish 1.6-Ma _] 2.1-Nu NaN 2.2-Nu NaN 110% host_id host_name neighbourhood_group neighbourhood latitude longitude room_ Not Trusted 2 > + < Python 3 (ipykernel) O Concordia 45.56401 -122.63472 Logout Pearl 45.52542 -122.68557 ENG IN E home E home 1:57 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit 1.1-Py View 1.2-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (autosaved) localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert In [17]: Out [17]: Cell Run 1.3-Fu id 619 4684661 1.3-Fu Kernel 3612 32246990 Hint- there should be no more than 5 choices. Widgets C Markdown 3 bedroom, "pet friendly" town home in 1.4-Sli 5192007 Help Q Search 1.5-Us DO Kelly And Rich 8. Most expensive ones? (please use the portland_original dataframe.) The price column is the price of each AirBnB per night. Let's assume that Dr. Song wants a luxury trip. Please help Dr. Song find the expensive AirBnBs in Portland that have a price higher than 1500. 1.6-Ma 2.1-Nu NaN 2.2-Nu NaN 110% Not Trusted name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type Charming quiet bohemian 24223207 Catherine urban getaway! 2 > + < Python 3 (ipykernel) O Richmond 45.49982 -122.62814 Montavilla 45.50574 -122.57099 Logout Entire home/apt Entire home/apt ENG IN 1:57 PM 2/20/2023 Xx ||| 1 CSC 32 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit In [18]: View 1.1-Py Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 2 minutes ago (autosaved) Kernel Widgets Out [18]: localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb In [19]: a 1.2-Py Insert e Out [19]: a e Cell 1.3-Fu Alex Tom 1.3-Fu Sammy Josh Jen Flossie dtype: object Alex Sammy Jen Run 9. Slicing a pandas series The line below creates a panda series for six names, and the indexes used are from a from f. Provide two different ways to select Alex, Sammy, and Jen. 1.4-Sli CMarkdown Help Q Search 1.5-Us DO x = pd. Series (['Alex', 'Tom', 'Sammy', 'Josh', 'Jen', 'Flossie'], index=list('abcdef')) X 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted 2 > + < Python 3 (ipykernel) O Logout ENG IN 1:57 PM 2/20/2023 Xx ||| 1 CSC 3 C Getting Started G Gmail 71F Partly sunny File + Mid X Edit View In [19]: Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 3 minutes ago (autosaved) Widgets Help 1.1-Py localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Out [19]: a e In [20]: 1.2-Py Out [20]: a e Insert Cell dtype: object Run Alex Sammy Jen dtype: object 1.3-Fu Alex Sammy Jen dtype: object 1.3-Fu Kernel 1.4-Sli C Markdown 1.5-Us DO Q Search # required - another solution 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted > + 10. data selection (please start from the portland_original dataframe. This dataframe should not be updated between question 6 to question 10.) < D Python 3 (ipykernel) O Logout ENG IN 1:58 PM 2/20/2023 Xx ||| 1 CSC 3 C Getting Started G Gmail 71F Partly sunny File Jupyter + Mid X Maps Edit In [24]: 1.1-Py YouTube 1.2-Py View localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert Cell 1.3-Fu Midterm1 - 322-2023 Last Checkpoint: 3 minutes ago (autosaved) Widgets Help Run 1.3-Fu portland_df = = portland_df Kernel 1.4-Sli C Markdown 1.5-Us DO Q Search 1.6-Ma 2.1-Nu 2.2-Nu 110% Not Trusted > + 10. data selection (please start from the portland_original dataframe. This dataframe should not be updated between question 6 to question 10.) Please follow the steps below - create a portland_df from portland_orginal by only selecting the column of 'id', 'name','price', 'last_review' and 'reviews_per_month'; do a fillna(0) and replace all the NaN values in your portland_df dataframe into 0. only keep the first 20 rows in your portland_df . Please note that this dataframe is using integer indexes. < D Hint- there are multiple ways to do this. You don't have to do the column selection and row selection in one line. Feel free to break this process into multiple lines or multiple cells. Python 3 (ipykernel) O Logout ENG IN 1:58 PM 2/20/2023 Xx ||| 1 I CSC 3 C Getting Started G Gmail 71F Partly sunny File Mid X Edit In [24]: 1.1-Py View Out [24]: Maps YouTube Jupyter Midterm 1 - 322-2023 Last Checkpoint: 3 minutes ago (autosaved) Widgets Help localhost:8888/notebooks/CSC 322/Midterm1 - 322-2023.ipynb Insert portland_df id portland_df 0 12899 1 16688 1.2-Py 2 25200 3 26203 4 29931 Cell 5 37676 6 39938 7 41601 8 42347 1.3-Fu Run = 1.3-Fu Kernel 1.4-Sli C Markdown 1.5-Us Q Search Alberta Arts 2 bedroom suite, charming 1906 house Beautiful condo in downtown Pearl, NW Portland Flamenco Dream :: hip mississippi ave. Bluebird @hip mississippi ave Lovely SW Victorian w/Bonus Room and Hot Tub Mt. Hood View in the Pearl District 125 Friendly Guesthouse / 10 Min to Airport & Down... 29 Grandpa's Bunkhouse-Backyard Studio 130 Portland is Accessible! 55 65 65 200 1.6-Ma name price last_review reviews_per_month 65 9/12/2019 275 9/8/2019 10/18/2018 8/19/2019 8/31/2019 8/31/2019 9/8/2019 9/15/2019 9/9/2019 2.1-Nu 2.2-Nu 110% Not Trusted 4.51 2.48 0.30 0.27 0.47 1.08 4.95 1.95 1.77 > + < D Logout Python 3 (ipykernel) O ENG IN 1:58 PM 2/20/2023 Xx ||| 1
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In late 2002, Albert (Al) Fiorini was becoming more and more frustrated and depressed. In September 2002, he had taken a leave of absence to return to school to earn his MBA, and he had trusted some...
-
Darrel & Co. makes electronic components. Chris Darrel, the president, recently instructed Vice President Jim Bruegger to develop a total quality control program. If we dont at least match the...
-
When are the adjacent values just the minimum and maximum observations?
-
Design a flowchart or pseudocode for a program that accepts three numbers from a user and displays a message if the sum of any two numbers equals the third.
-
Derive Equation 3.66. Uf 2vm + (3.66) E2 Vi+n2vm Et Em
-
Transmissions are delivered to the fabrication line four at a time. It takes one hour for transmissions to be delivered. Approximately four vehicles are produced each hour, and management has decided...
-
2. Does the surveillance camera present any ethical or legal problems? Why or why not? 3. Explain any other legal issues regarding employee or employer rights that might apply. 4. Do you think the...
-
On March 31, the following data were accumulated to assist the accountant in preparing the adjusting entries for Potomac Realty: a. The supplies account balance on March 31 is $5,620, the supplies on...
-
Complete the following compound interest chart. Complete the chart (Round to two decimal places as needed.) Compounding Period Principal Annual Rate Time (Years) Interest Rate Per Period Number of...
-
Depreciation by three methods; partial years Perdue Company purchased equipment on April 1 for $116,910. The equipment was expected to have a useful life of 3 years, or 8,100 operating hours, and a...
-
Use Form 601 to identify the features and functions you think are needed for a hospital. Find Websites for two project management software vendors. Compare their products against MS Project and...
-
You are hired as a production manager within a small manufacturing firm that produces wood furniture for homes. You ask the company owner who is the CEO what the environmental management plan is. He...
-
In the Design-Bid-Build (DBB) and Design-Build(DB) project delivery methods: Identify for the following scenarios: Scenario: 1) A small rural municipality has the town library to be built in the...
-
Jimmy B-Rabbit Smith Jr. (Eminem) wants to be a successful rapper and to prove that a white man can create moving sounds. He works days at a plant run by the North Detroit Stamping Company and...
-
The first national bank pays a 4% interest rate compound continuously. The effective annual rate paid by the bank is __________. a. 4.16% b. 4.20% c. 4.08% d. 4.12%
-
In Original Source 1, the researchers addressed some limitations with the study. One of them was: First, there was a relatively small number of subjects who participated and this limited our...
-
A standard protocol for the treatment of all participants that must be strictly followed. Exercises 12 to 21: Explain the main ethical issue of concern in each of the following. Discuss what, if...
-
For each of the following situations, would a chi-square test based on a 232 table using a level of 0.01 be statistically significant? Justify your answer. a. chi-square statistic 5 1.42 b....
-
How a shaper is specified?
-
What is the purpose of a drilling machine ? Explain its working principle.
-
Describe the quick return motion mechanism for a shaper.
Study smarter with the SolutionInn App