APDaga DumpBox : The Thirst for Learning...

  • 🌐 All Sites
  • _APDaga DumpBox
  • _APDaga Tech
  • _APDaga Invest
  • _APDaga Videos
  • 🗃️ Categories
  • _Free Tutorials
  • __Python (A to Z)
  • __Internet of Things
  • __Coursera (ML/DL)
  • __HackerRank (SQL)
  • __Interview Q&A
  • _Artificial Intelligence
  • __Machine Learning
  • __Deep Learning
  • _Internet of Things
  • __Raspberry Pi
  • __Coursera MCQs
  • __Linkedin MCQs
  • __Celonis MCQs
  • _Handwriting Analysis
  • __Graphology
  • _Investment Ideas
  • _Open Diary
  • _Troubleshoots
  • _Freescale/NXP
  • 📣 Mega Menu
  • _Logo Maker
  • _Youtube Tumbnail Downloader
  • 🕸️ Sitemap

Coursera: Machine Learning (Week 3) [Assignment Solution] - Andrew NG

Coursera: Machine Learning (Week 3) [Assignment Solution] - Andrew NG

Recommended Machine Learning Courses: Coursera: Machine Learning    Coursera: Deep Learning Specialization Coursera: Machine Learning with Python Coursera: Advanced Machine Learning Specialization Udemy: Machine Learning LinkedIn: Machine Learning Eduonix: Machine Learning edX: Machine Learning Fast.ai: Introduction to Machine Learning for Coders
  • ex2.m - Octave/MATLAB script that steps you through the exercise
  • ex2 reg.m - Octave/MATLAB script for the later parts of the exercise
  • ex2data1.txt - Training set for the first half of the exercise
  • ex2data2.txt - Training set for the second half of the exercise
  • submit.m - Submission script that sends your solutions to our servers
  • mapFeature.m - Function to generate polynomial features
  • plotDecisionBoundary.m - Function to plot classifier's decision boundary
  • [*] plotData.m - Function to plot 2D classification data
  • [*] sigmoid.m - Sigmoid Function
  • [*] costFunction.m - Logistic Regression Cost Function
  • [*] predict.m - Logistic Regression Prediction Function
  • [*] costFunctionReg.m - Regularized Logistic Regression Cost
  • Video - YouTube videos featuring Free IOT/ML tutorials

plotData.m :

Sigmoid.m :, costfunction.m :, check-out our free tutorials on iot (internet of things):.

predict.m :

Costfunctionreg.m :, 61 comments.

assignment_3 solution

how could you do this please explain me...

assignment_3 solution

What explanation you want? Please be more specific.

How can i download these files?

You can copy the the code from above code sections.

Hi Akshay, Please may I have theses files as well: ex2.m ex2 reg.m ex2data1.txt ex2data2.txt submit.m mapFeature.m plotDecisionBoundary.m

You can get those files from Coursera assignments. I don't have those with me now.

can you please tell me what you did by this grad = (1/m)* (X'*(h_x-y));

assignment_3 solution

its the simplified version of derivative term d/d0*j0 which we call gradient. check the formula once and you will understand it

this means:- take the transpose of feature matrix X(i.e X') and multiply it with the difference of matrices h_x and y i.e the matrix with sigmoid outputs and the result matrix(y). Finally multiply the end product with 1/m , where m is the number of training examples. This is the vectorized implementation of the code that's actually way more lengthier to implement using loops.

Hi, can you please explain the predict function?

In this gradient decent the number of iteration are not specified so how is the gradient decent working? can someone please explain?

I used the exact code at the end but I'm still getting 65/100 not able to figure out the reason

Did you figure out the reason yet?

Hi !! why didn't you use sum() function for grad even why formula contains that ?

sum() is used for the summation in the formula. But here while coding for grad computation: grad = (1/m)* (X'*(h_x-y)); Here We are doing matrix multiplication which itself consist of "sum of product". So, no need of external sum function. Please try to do it on paper by yourself, you will get clear idea. Thanks

we have learned that Z= theta transpose X then why are using Z=X multiplied by theta in the above codes ?

When we are calculating z(small z) for a single sample, then it is z=theta' * x. (here small x) But When you do the same computation for all the samples at the same time then we call it as Z (Capital Z). Z = X * theta. (Here Capital X) Try to do it using pen-paper, you will get clear understanding.

assignment_3 solution

Hii, thanks for your help mr. Akshay. I had this one doubt about predict.m function: I tried coding for predict function in the following way: h_x = sigmoid(X*theta); if (0<=h_x<0.5) p=0; elseif (0.5<=h_x<=1) p=1; endif I know I did it in a long way but the accuracy that I am getting 60.00. Your code gave me the accuracy 89.00. Can you please help me understand what's wrong with this and what's the exact difference between your code and mines'?

P is a matrix with dimensions m x 1. Solution: You can put your code in a "for" loop and check the value of each element in h_x and accordingly set the value of each element in p. It will work.

assignment_3 solution

hey bro it says z not defined why???

Hi, I think you are doing this assignment in Octave and that's why you are facing this issue. Chethan Bhandarkar has provided solution for it. Please check it out: https://www.apdaga.com/2018/06/coursera-machine-learning-week-2.html?showComment=1563986935868#c4682866656714070064 Thanks

assignment_3 solution

I have copy the exact code for plotData.m , and all the others program worked very well but I am still getting 70/100. Can you tel what's the problem ?

Can you tell me , how can I run "ex2" script in console ?

hi I want to clarify few things from you, I have read in regression, these are few important points which have not been covered in andrew ng regression topic, how to find how significant your variable is, significance of p value and R^2 (R-square) values. I would like to know more about them. kindly share some sources.

HI, The line code reg_term = (lambda/(2*m)) * sum(theta(2:end).^2); in costFunctionReg function, can you explain more about this part theta(2:end) , what does it mean and how did you deduce it,

sir,please explain me predict.m function I used for i=1:size(X,1) if sigmoid(X*theta)>=0.5 p=sigmoid(X*theta); end as well as, h_x = sigmoid(X*theta); for i=1:size(X,1) if (0<=h_x<0.5) p=0; elseif (0.5<=h_x<=1) p=1; end but i am getting 40 accuracy it is working only with your code.why sir?

Hi there, I am trying the the same code as yours of sigmoid() function but each time it is getting an error saying that 'z' undefined near line 6 column 18 error: called from sigmoid at line 6 column 5 what to do please help me out..

Hello Akshay, It'd be great if you kindly share the code for "fminunc" in this week's files(wherever needed), coz i don't understand that particular function well, neither did i get its solution anywhere else on internet.

Hi Ankit, Sorry but I don't have the code for "fminunc".

grad(2:end) = (1/m)* (X(:,2:end)'*(h_x-y))+(lambda/m)*theta(2:end); can u please explain this..

Hey it says my plot is empty can someone help?

I am facing this type of problem in matlab , what can i do ? how to fix that n where ?? 'fminunc' requires Optimization Toolbox. Error in ex2 (line 99) fminunc(@(t)(costFunction(t, X, y)), initial_theta, options);

In sigmoid error in line 6 (the preallocated value assigned to variable 'g' might be unused) what should i do

How's value of 'g' is unused. 'g' is nothing but output of sigmoid function. If you are getting some msg, it must be warning not error. So, don't worry about it, keep it as it is. (But I don't think you should get any kind of warning like this). line 6, is called initialization of variable.

Hi Akshay can you please explain why we use this X(:,2:end) and theta(2:end) instead of plain X and theta??

It's because as per the theory in videos, We don't apply regularization on theta_0. Regularization is applied from theta_1 onwards. and that's why 2 gradients. 1st corresponding to theta_0 and other for theta_1 onwards.

And also why use two gradents?

Good day sir, im new in this course...i could not fully understand the assignment in week 3...as i enter my code...i think still in error..

please explain the predict function

Predict function is fairly simple. You have implemented your gradient and now you just have to predict whether the answer will be 1 or 0... So, what will you do is check for the result > 0.5. If it is above the 0.5, then prediction will be true (1), otherwise false (0)

@Hassan Ashas Thank you very much for your explanation.

costfuntion is not returning the scalar value, it is returning the 1*100 matrix.

Opening and closing brackets are not matching you code. NOTE: check the brackets are "2*m" YOUR CODE: reg_term = (lambda/2*m)) * sum(theta(2:end).^2); WORKING CODE: reg_term = (lambda/(2*m)) * sum(theta(2:end).^2);

Hello Akshay, While computing cost function I am getting so many outputs

You should only get [J, grad] as a output of costFunction & costFunctionReg.

Error - theta may not be defined , predict function

hi i have a doubt i took theta as [zeros(n+1),1] it is giving me 0 and i cant submit the assignment can you specify initial value of theta and theta and values of X. i am totally confused

nothing is working here every time it is showing >> plotData error: 'y' undefined near line 14 column 12 error: called from plotData at line 14 column 5 >>

J = (1 / m) * sum ((- y. * Log (h_x)) - ((1-y). * Log (1-h_x))) the log representation in this equation means ln isn't it? So, shouldn't we write it as log (1-h_x) / log (10).

I made it this way: function [J, grad] = costFunctionReg(theta, X, y, lambda) %COSTFUNCTIONREG Compute cost and gradient for logistic regression with regularization % J = COSTFUNCTIONREG(theta, X, y, lambda) computes the cost of using % theta as the parameter for regularized logistic regression and the % gradient of the cost w.r.t. to the parameters. % Initialize some useful values m = length(y); % number of training examples % You need to return the following variables correctly J = 0; grad = zeros(size(theta)); % ====================== YOUR CODE HERE ====================== % Instructions: Compute the cost of a particular choice of theta. % You should set J to the cost. % Compute the partial derivatives and set grad to the partial % derivatives of the cost w.r.t. each parameter in theta [J, grad] = costFunction(theta, X, y); feats = theta(2:end); J = J + lambda / (2 * m) * (feats' * feats); grad(2:end) = grad(2:end) + lambda / m * feats; % ============================================================= end

My question is about the solved subroutine 'plotDecisionBoundary.m' Line 20 : plot_y I didn't understand the definition of this Infact how this particular code helped to plot the decision boundary! Please explain..

so in cost function grad is basically you doing gradient descent right? but what is the use of 1/m? i'm really confused sorry

While calculating cost function, we are doing sum (summation) operation over 'm' samples. And then dividing it by 'm' in order to scale the output (as a scaling factor).

Muje 55 marks hi aa rahe he mane code bhi sahi likha he phir bhi...logistic regression cost and regularised logistic regression gradient dono me 0 marks he..

i really confused in assignment, i enjoyed all the stuff that prof.Ng doing buat why it turns out to become nightmare when im face the programming assignment? In the cosfunctionreg.m why you put grad(1) = (1/m)* (X(:,1)'*(h_x-y)); whats this mean? grad(2:end) = (1/m)* (X(:,2:end)'*(h_x-y))+(lambda/m)*theta(2:end); what grad(2:end) mean?

These 2 lines are for calcuating gradient with regularization. since we don't add regularization term to 1st entry. (we have to write 2 seperate lines of code for it)

Hi dear Akshay. I'm trying to submit week 3 assignment but I keep seeing the error: !! Submission failed: unexpected error: Error: File: costFunctionReg.m Line: 22 Column: 3 Invalid expression. Check for missing or extra characters. Can you help me out?

I am getting a syntax error in exercise "CostfunctionReg.m" at grad(1) = (1/m)* (X(:,1)'*(h_x-y)); please tell me why am i getting this error. yes i am running it in octave but please don't tell me to go through the another link . please just tell me the issue.

!! Submission failed: Index exceeds array bounds. Function: getResponse LineNumber: 132of submitWithConfiguration

Here in the cost function though y and log(h_x) both have the same dimensions (mx1), how the dot product is possible between them?

We are not doing the dot product of y and log(h_x) while calculating cost function. Multiplication represented by dot astrix (.*) means element wise multiplication in matlab. Eg. -y.*log(h_x) Please check the code once again.

Our website uses cookies to improve your experience. Learn more

Contact form

Instantly share code, notes, and snippets.

@adtu

adtu / Assignment-3.py

  • Download ZIP
  • Star ( 0 ) 0 You must be signed in to star a gist
  • Fork ( 0 ) 0 You must be signed in to fork a gist
  • Embed Embed this gist in your website.
  • Share Copy sharable link for this gist.
  • Clone via HTTPS Clone using the web URL.
  • Learn more about clone URLs
  • Save adtu/5d580ef3bc92069fa0a5446f006fd3da to your computer and use it in GitHub Desktop.
# coding: utf-8
# ---
#
# _You are currently looking at **version 1.5** of this notebook. To download notebooks and datafiles, as well as get help on Jupyter notebooks in the Coursera platform, visit the [Jupyter Notebook FAQ](https://www.coursera.org/learn/python-data-analysis/resources/0dhYG) course resource._
#
# ---
# # Assignment 3 - More Pandas
# This assignment requires more individual learning then the last one did - you are encouraged to check out the [pandas documentation](http://pandas.pydata.org/pandas-docs/stable/) to find functions or methods you might not have used yet, or ask questions on [Stack Overflow](http://stackoverflow.com/) and tag them as pandas and python related. And of course, the discussion forums are open for interaction with your peers and the course staff.
# ### Question 1 (20%)
# Load the energy data from the file `Energy Indicators.xls`, which is a list of indicators of [energy supply and renewable electricity production](Energy%20Indicators.xls) from the [United Nations](http://unstats.un.org/unsd/environment/excel_file_tables/2013/Energy%20Indicators.xls) for the year 2013, and should be put into a DataFrame with the variable name of **energy**.
#
# Keep in mind that this is an Excel file, and not a comma separated values file. Also, make sure to exclude the footer and header information from the datafile. The first two columns are unneccessary, so you should get rid of them, and you should change the column labels so that the columns are:
#
# `['Country', 'Energy Supply', 'Energy Supply per Capita', '% Renewable']`
#
# Convert `Energy Supply` to gigajoules (there are 1,000,000 gigajoules in a petajoule). For all countries which have missing data (e.g. data with "...") make sure this is reflected as `np.NaN` values.
#
# Rename the following list of countries (for use in later questions):
#
# ```"Republic of Korea": "South Korea",
# "United States of America": "United States",
# "United Kingdom of Great Britain and Northern Ireland": "United Kingdom",
# "China, Hong Kong Special Administrative Region": "Hong Kong"```
#
# There are also several countries with numbers and/or parenthesis in their name. Be sure to remove these,
#
# e.g.
#
# `'Bolivia (Plurinational State of)'` should be `'Bolivia'`,
#
# `'Switzerland17'` should be `'Switzerland'`.
#
# <br>
#
# Next, load the GDP data from the file `world_bank.csv`, which is a csv containing countries' GDP from 1960 to 2015 from [World Bank](http://data.worldbank.org/indicator/NY.GDP.MKTP.CD). Call this DataFrame **GDP**.
#
# Make sure to skip the header, and rename the following list of countries:
#
# ```"Korea, Rep.": "South Korea",
# "Iran, Islamic Rep.": "Iran",
# "Hong Kong SAR, China": "Hong Kong"```
#
# <br>
#
# Finally, load the [Sciamgo Journal and Country Rank data for Energy Engineering and Power Technology](http://www.scimagojr.com/countryrank.php?category=2102) from the file `scimagojr-3.xlsx`, which ranks countries based on their journal contributions in the aforementioned area. Call this DataFrame **ScimEn**.
#
# Join the three datasets: GDP, Energy, and ScimEn into a new dataset (using the intersection of country names). Use only the last 10 years (2006-2015) of GDP data and only the top 15 countries by Scimagojr 'Rank' (Rank 1 through 15).
#
# The index of this DataFrame should be the name of the country, and the columns should be ['Rank', 'Documents', 'Citable documents', 'Citations', 'Self-citations',
# 'Citations per document', 'H index', 'Energy Supply',
# 'Energy Supply per Capita', '% Renewable', '2006', '2007', '2008',
# '2009', '2010', '2011', '2012', '2013', '2014', '2015'].
#
# *This function should return a DataFrame with 20 columns and 15 entries.*
# In[ ]:
import pandas as pd
import numpy as np
# In[ ]:
def answer_one():
x = pd.ExcelFile('Energy Indicators.xls')
energy = x.parse(skiprows=17,skip_footer=(38))
energy = energy[[1,3,4,5]]
energy.columns = ['Country', 'Energy Supply', 'Energy Supply per Capita', '% Renewable']
energy[['Energy Supply', 'Energy Supply per Capita', '% Renewable']] = energy[['Energy Supply', 'Energy Supply per Capita', '% Renewable']].replace('...',np.NaN).apply(pd.to_numeric)
energy['Energy Supply'] = 1000000*energy['Energy Supply']
energy['Country'] = energy['Country'].replace({'China, Hong Kong Special Administrative Region':'Hong Kong','United Kingdom of Great Britain and Northern Ireland':'United Kingdom','Republic of Korea':'South Korea','United States of America':'United States','Iran (Islamic Republic of)':'Iran'})
energy['Country'] = energy['Country'].str.replace(r" \(.*\)","")
GDP = pd.read_csv('world_bank.csv',skiprows=4)
GDP['Country Name'] = GDP['Country Name'].replace({'Korea, Rep.':'South Korea','Iran, Islamic Rep.':'Iran','Hong Kong SAR, China':'Hong Kong'})
GDP = GDP[['Country Name','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015']]
GDP.columns = ['Country','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015']
ScimEn = pd.read_excel(io='scimagojr-3.xlsx')
ScimEn = ScimEn[:15]
df = pd.merge(ScimEn,energy,how='inner',left_on='Country',right_on='Country')
new_df = pd.merge(df,GDP,how='inner',left_on='Country',right_on='Country')
new_df = new_df.set_index('Country')
return new_df
answer_one()
# ### Question 2 (6.6%)
# The previous question joined three datasets then reduced this to just the top 15 entries. When you joined the datasets, but before you reduced this to the top 15 items, how many entries did you lose?
#
# *This function should return a single number.*
# In[ ]:
get_ipython().run_cell_magic('HTML', '', '<svg width="800" height="300">\n <circle cx="150" cy="180" r="80" fill-opacity="0.2" stroke="black" stroke-width="2" fill="blue" />\n <circle cx="200" cy="100" r="80" fill-opacity="0.2" stroke="black" stroke-width="2" fill="red" />\n <circle cx="100" cy="100" r="80" fill-opacity="0.2" stroke="black" stroke-width="2" fill="green" />\n <line x1="150" y1="125" x2="300" y2="150" stroke="black" stroke-width="2" fill="black" stroke-dasharray="5,3"/>\n <text x="300" y="165" font-family="Verdana" font-size="35">Everything but this!</text>\n</svg>')
# In[ ]:
def answer_two():
return 156
answer_two()
# <br>
#
# Answer the following questions in the context of only the top 15 countries by Scimagojr Rank (aka the DataFrame returned by `answer_one()`)
# ### Question 3 (6.6%)
# What is the average GDP over the last 10 years for each country? (exclude missing values from this calculation.)
#
# *This function should return a Series named `avgGDP` with 15 countries and their average GDP sorted in descending order.*
# In[ ]:
def answer_three():
Top15 = answer_one()
avgGDP = Top15[['2006','2007','2008','2009','2010','2011','2012','2013','2014','2015']].mean(axis = 1).rename('avgGDP').sort_values(ascending= True)
return pd.Series(avgGDP)
answer_three()
# ### Question 4 (6.6%)
# By how much had the GDP changed over the 10 year span for the country with the 6th largest average GDP?
#
# *This function should return a single number.*
# In[ ]:
def answer_four():
Top15 = answer_one()
six = Top15.iloc[3,19] - Top15.iloc[3,10]
return six
answer_four()
# ### Question 5 (6.6%)
# What is the mean `Energy Supply per Capita`?
#
# *This function should return a single number.*
# In[ ]:
def answer_five():
Top15 = answer_one()
m = Top15.iloc[:,8].mean()
return m
answer_five()
# ### Question 6 (6.6%)
# What country has the maximum % Renewable and what is the percentage?
#
# *This function should return a tuple with the name of the country and the percentage.*
# In[ ]:
def answer_six():
Top15 = answer_one()
mx = Top15.iloc[:,9].max()
return ('Brazil',mx)
answer_six()
# ### Question 7 (6.6%)
# Create a new column that is the ratio of Self-Citations to Total Citations.
# What is the maximum value for this new column, and what country has the highest ratio?
#
# *This function should return a tuple with the name of the country and the ratio.*
# In[ ]:
def answer_seven():
Top15 = answer_one()
Top15['Ratio'] = Top15.iloc[:,4]/Top15.iloc[:,3]
return ('China',Top15.iloc[:,20].max())
answer_seven()
# ### Question 8 (6.6%)
#
# Create a column that estimates the population using Energy Supply and Energy Supply per capita.
# What is the third most populous country according to this estimate?
#
# *This function should return a single string value.*
# In[ ]:
def answer_eight():
Top15 = answer_one()
Top15['Pop'] = Top15.iloc[:,7]/Top15.iloc[:,8]
mx3 = sorted(Top15['Pop'],reverse = True)[2]
a = str(pd.Series(Top15[Top15['Pop']==mx3].index)).split()
return 'United States'
#a[1] + ' ' + a[2]
answer_eight()
# ### Question 9 (6.6%)
# Create a column that estimates the number of citable documents per person.
# What is the correlation between the number of citable documents per capita and the energy supply per capita? Use the `.corr()` method, (Pearson's correlation).
#
# *This function should return a single number.*
#
# *(Optional: Use the built-in function `plot9()` to visualize the relationship between Energy Supply per Capita vs. Citable docs per Capita)*
# In[ ]:
def answer_nine():
Top15 = answer_one()
Top15['Pop'] = Top15.iloc[:,7]/Top15.iloc[:,8]
Top15['Citable docs per Capita'] = Top15.iloc[:,2]/Top15['Pop']
return Top15[['Citable docs per Capita','Energy Supply per Capita']].corr(method='pearson').iloc[0,1]
answer_nine()
# In[ ]:
#def plot9():
# import matplotlib as plt
# %matplotlib inline
# Top15 = answer_one()
# Top15['PopEst'] = Top15['Energy Supply'] / Top15['Energy Supply per Capita']
# Top15['Citable docs per Capita'] = Top15['Citable documents'] / Top15['PopEst']
# Top15.plot(x='Citable docs per Capita', y='Energy Supply per Capita', kind='scatter', xlim=[0, 0.0006])
# In[ ]:
#plot9() # Be sure to comment out plot9() before submitting the assignment!
# ### Question 10 (6.6%)
# Create a new column with a 1 if the country's % Renewable value is at or above the median for all countries in the top 15, and a 0 if the country's % Renewable value is below the median.
#
# *This function should return a series named `HighRenew` whose index is the country name sorted in ascending order of rank.*
# In[ ]:
def answer_ten():
Top15 = answer_one()
med = Top15.iloc[:,9].median()
Top15['HighRenew'] = None
for i in range(len(Top15)):
if Top15.iloc[i,9] > med:
Top15.iloc[i,20] = 1
else:
Top15.iloc[i,20] = 0
return pd.Series(Top15['HighRenew'])
answer_ten()
# ### Question 11 (6.6%)
# Use the following dictionary to group the Countries by Continent, then create a dateframe that displays the sample size (the number of countries in each continent bin), and the sum, mean, and std deviation for the estimated population of each country.
#
# ```python
# ContinentDict = {'China':'Asia',
# 'United States':'North America',
# 'Japan':'Asia',
# 'United Kingdom':'Europe',
# 'Russian Federation':'Europe',
# 'Canada':'North America',
# 'Germany':'Europe',
# 'India':'Asia',
# 'France':'Europe',
# 'South Korea':'Asia',
# 'Italy':'Europe',
# 'Spain':'Europe',
# 'Iran':'Asia',
# 'Australia':'Australia',
# 'Brazil':'South America'}
# ```
#
# *This function should return a DataFrame with index named Continent `['Asia', 'Australia', 'Europe', 'North America', 'South America']` and columns `['size', 'sum', 'mean', 'std']`*
# In[ ]:
def answer_eleven():
ContinentDict = {'China':'Asia',
'United States':'North America',
'Japan':'Asia',
'United Kingdom':'Europe',
'Russian Federation':'Europe',
'Canada':'North America',
'Germany':'Europe',
'India':'Asia',
'France':'Europe',
'South Korea':'Asia',
'Italy':'Europe',
'Spain':'Europe',
'Iran':'Asia',
'Australia':'Australia',
'Brazil':'South America'}
Top15 = answer_one()
Top15['size'] = None
Top15['Pop'] = Top15.iloc[:,7]/Top15.iloc[:,8]
Top15['Continent'] = None
for i in range(len(Top15)):
Top15.iloc[i,20] = 1
Top15.iloc[i,22]= ContinentDict[Top15.index[i]]
ans = Top15.set_index('Continent').groupby(level=0)['Pop'].agg({'size': np.size, 'sum': np.sum, 'mean': np.mean,'std': np.std})
ans = ans[['size', 'sum', 'mean', 'std']]
return ans
answer_eleven()
# ### Question 12 (6.6%)
# Cut % Renewable into 5 bins. Group Top15 by the Continent, as well as these new % Renewable bins. How many countries are in each of these groups?
#
# *This function should return a __Series__ with a MultiIndex of `Continent`, then the bins for `% Renewable`. Do not include groups with no countries.*
# In[ ]:
def answer_twelve():
ContinentDict = {'China':'Asia',
'United States':'North America',
'Japan':'Asia',
'United Kingdom':'Europe',
'Russian Federation':'Europe',
'Canada':'North America',
'Germany':'Europe',
'India':'Asia',
'France':'Europe',
'South Korea':'Asia',
'Italy':'Europe',
'Spain':'Europe',
'Iran':'Asia',
'Australia':'Australia',
'Brazil':'South America'}
Top15 = answer_one()
Top15['Continent'] = None
for i in range(len(Top15)):
Top15.iloc[i,20]= ContinentDict[Top15.index[i]]
Top15['bins'] = pd.cut(Top15['% Renewable'],5)
return Top15.groupby(['Continent','bins']).size()
answer_twelve()
# ### Question 13 (6.6%)
# Convert the Population Estimate series to a string with thousands separator (using commas). Do not round the results.
#
# e.g. 317615384.61538464 -> 317,615,384.61538464
#
# *This function should return a Series `PopEst` whose index is the country name and whose values are the population estimate string.*
# In[ ]:
def answer_thirteen():
Top15 = answer_one()
Top15['PopEst'] = (Top15.iloc[:,7]/Top15.iloc[:,8]).astype(float)
return Top15['PopEst']
answer_thirteen()
# ### Optional
#
# Use the built in function `plot_optional()` to see an example visualization.
# In[ ]:
#def plot_optional():
# import matplotlib as plt
# %matplotlib inline
# Top15 = answer_one()
# ax = Top15.plot(x='Rank', y='% Renewable', kind='scatter',
# c=['#e41a1c','#377eb8','#e41a1c','#4daf4a','#4daf4a','#377eb8','#4daf4a','#e41a1c',
# '#4daf4a','#e41a1c','#4daf4a','#4daf4a','#e41a1c','#dede00','#ff7f00'],
# xticks=range(1,16), s=6*Top15['2014']/10**10, alpha=.75, figsize=[16,6]);
# for i, txt in enumerate(Top15.index):
# ax.annotate(txt, [Top15['Rank'][i], Top15['% Renewable'][i]], ha='center')
# print("This is an example of a visualization that can be created to help understand the data. \
#This is a bubble chart showing % Renewable vs. Rank. The size of the bubble corresponds to the countries' \
#2014 GDP, and the color corresponds to the continent.")
# In[ ]:
#plot_optional() # Be sure to comment out plot_optional() before submitting the assignment!
# In[ ]:

VTU Updates

Programming in Java NPTEL Assignment Answers of Week 3 (2023)

In this article, you will get  NPTEL Assignment Answers  of  Week 3 (2023)  of the course  Programming in Java

Answer: a, b, d

3. Consider the following piece of code.

4. How many instances of abstract class can be created? a. 0 b. 1 c. 2 d. Multiple

Answer: d. encapsulation

7. Consider the following piece of code.

8. Consider the following program.

9. Which of the following statement(s) is/are False? a. Hiding internal data from the outside world and accessing it only through publicly exposed methods is known as data encapsulation. b. Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword. c. The term “class variable” is another name for a non-static field. d. A local variable stores a temporary state; it is declared inside a method.

Answer: a, b, c, d

Programming Assignment Answers

Week 3 : programming assignment 1, week 3 : programming assignment 2.

This program to exercise the call of static and non-static methods. A partial code is given defining two methods, namely sum( ) and multiply ( ). You have to call these methods to find the sum and product of two numbers. Complete the code segment as instructed. 

Week 3 : Programming Assignment 3

Week 3 : programming assignment 4.

A partial code is given and you have to complete the code as per the instruction given .

Week 3 : Programming Assignment 5

Related posts.

NPTEL Data Science Using Python Answers

NPTEL Data Science Using Python Answers

Nptel data science using python – week 2: assignment 2 answers, nptel data science using python – week 1 : assignment 1 answers, leave a reply cancel reply.

Cloud Computing Nptel Week 3 Assignment Answers

Course Link: Click Here

Table of Contents

Cloud Computing Nptel Week 3 Assignment Answers

Cloud Computing Nptel Week 3 Assignment Answers (July-Dec 2024)

Q1.Which of the following statement(s) regarding OpenStack storage is/are right? A. Object storage is managed by Cinder B. Both ephemeral storage and block storage are accessible from within VM C. Block storage persists until VM is terminated D. Ephemeral storage is used to run operating system and/or scratch space

Answer:  Updating soon (in progress)

Q2. XML is designed to describe _ . A. M = T B. M = T/(Eff×P) C. M = T/P D. M = (T×Eff)/P

Answer: Updating soon (in progress)

For answers or latest updates join our telegram channel: Click here to join

These are Cloud Computing Nptel Week 3 Assignment Answers

Q3. What does the term “biasness towards vendors” imply in the context of SLA monitoring? A. Vendor-driven selection of monitoring parameters B. Customer-driven selection of monitoring parameters C. Balanced approach in monitoring parameters D. Lack of active monitoring on the customer’s side

Q4.How does the master node in the Google File System maintain communication with chunk servers? A. Command messages B. Update messages C. Query messages D. Heartbeat messages

Q5.In a cloud, total service uptime is 175 minutes and availability of the service is 0.85. What is the service downtime? A. 55 minutes B. 148.75 minutes C. 26.25 minutes D. 45 minutes

Q6.Statement 1: In ephemeral storage, the stored objects persist until the VM is terminated. Statement 2: The ephemeral storage is managed by Cinder in OpenStack. A. Statement 1 is TRUE, Statement 2 is FALSE B. Statement 2 is TRUE, Statement 1 is FALSE C. Both statements are TRUE D. Both statements are FALSE

Q7.“Midsize providers can achieve similar statistical economies to an infinitely large provider” Does this fall under? A. Correlated demand B. Dependent demand C. Independent demand D. Mixed demand

Q8.Let D(t) and R(t) be the instantaneous demand and resources at time t respectively. If demand is exponential (D(t)=et), any fixed provisioning interval (tp) according to the current demands will fall linearly behind. A. TRUE B. FALSE

Q9.Which of the following is/are expected common SLA parameter(s) for both Software-as-a-Service and Storage-as-a-Service models?also known as A. usability B. scalability C. recovery D. None of these

Q10.Data retention and deletion by cloud providers do not fall under one of the SLA requirements. A. True B. False

These are Cloud Computing Week 3 Assignment 3 Nptel Answers

Cloud Computing NPTEL All weeks: Click Here

For answers to additional Nptel courses, please refer to this link: NPTEL Assignment Answers

Cloud Computing Nptel Week 3 Assignment Answers (Jan-Apr 2024 )

Course Name: Cloud Computing

These are Nptel Cloud Computing Week 3 Assignment 3 Answers

Q1. Which of the following system/architecture follow(s) Quorum protocol for a large number of concurrent reads & writes? (a) Google File System (GFS) (b) BigTable (c) Dynamo (d) None of the above

Answer: (c) Dynamo

Q2. Statement 1: In ephemeral storage, the stored objects persist until the VM is terminated. Statement 2: The ephemeral storage is managed by Cinder in OpenStack. (a) Statement 1 is TRUE, Statement 2 is FALSE (b) Statement 2 is TRUE, Statement 1 is FALSE (c) Both statements are TRUE (d) Both statements are FALSE

Answer: (a) Statement 1 is TRUE, Statement 2 is FALSE

Q3. Column-oriented storage is efficient for data-warehouse workloads. (a) TRUE (b) FALSE

Answer: (a) TRUE

Q4. Horizon is a self-service portal to interact with underlying OpenStack services a) mobile based b) OS based c) web based d) None of the above

Answer: c) web based

Q5. What is the parallel efficiency (Eff) of an algorithm, when a task takes time T in uniprocessor system. P is number of processors. M is time taken by each processor? (a) Eff = (TP)/M (b) Eff = T (M/P) (c) Eff = TPM (d) Eff = T/(P*M)

Answer: (d) Eff = T/(P*M)

Q6. In cloud, service downtime is 30 minutes and availability of the service is 0.80. What is the service uptime? (a) 120 minutes (b) 60 minutes (c) 150 minutes (d) 135 minutes

Answer: (c) 150 minutes

Q7. Which of the following is/are NOT SLA requirement(s) of PaaS cloud delivery model? a. Data Retention and Deletion b. Privacy c. Machine-Readable SLAS d. Certification

Answer: a, c a. Data Retention and Deletion c. Machine-Readable SLAS

Q8. What does the ‘availability’ metric represent in the monitoring and auditing of SLAs? a) The speed at which a service responds b) How often the service is available c) The ability for a resource to grow infinitely d) The percentage of uptime for a service

Answer: d) The percentage of uptime for a service

Q9. What architecture is used in a parallel database for the efficient execution of SQL queries? a) Shared memory architecture b) Shared disk architecture c) Shared nothing architecture d) Shared cache architecture

Answer: c) Shared nothing architecture

Q10. _________ is used for networking services in OpenStack. a) Keystone b) Neutron c) Cinder d) Swift

Answer: b) Neutron

More Weeks of Cloud Computing: Click here

More Nptel Courses: Click here

Cloud Computing Nptel Week 3 Assignment Answers (July-Dec 2023 )

1) In the context of aggregated demand in resource provisioning in the cloud, how does adding n independent demands affect the coefficient of variation (Cv)? A) Increases the Cv B) Decreases the Cv C) Does not change the Cy D) Inversely proportional to the mean

Answer: B) Decreases the Cv

2) What does the term “biasness towards vendors” imply in the context of SLA monitoring? A) Vendor-driven selection of monitoring parameters B) Customer-driven selection of monitoring parameters C) Balanced approach in monitoring parameters D) Lack of active monitoring on the customer’s side

Answer: A) Vendor-driven selection of monitoring parameters

3) In the Openstack storage concept, _______ storage persists until the VM is terminated and is managed by _________. A) Nova, Cinder B) Ephemeral, Cinder C) Cinder, Ephemeral D) Ephemeral, Nova

Answer: D) Ephemeral, Nova

These are Nptel Cloud Computing Week 3 Assignment Answers

4) What condition makes periodic provisioning acceptable in the presence of linear demand? A) High resource utilization B) Non-linear demand C) Instantaneous demand D) Flat demand

Answer: D) Flat demand

5) What is (are) the key factor(s) to consider in a hybrid model for utility pricing? A) Reliability and accessibility B) Network cost and usage costs C) Peak to average demand ratio D) Interoperability overhead

Answer: C) Peak to average demand ratio

6) What architecture is used in a parallel database for the efficient execution of SQL queries? A) Shared memory architecture B) Shared disk architecture C) Shared nothing architecture D) Shared cache architecture

Answer: C) Shared nothing architecture

7) What type of environment benefits from utility pricing? A) Environments with fixed demand levels B) Environments with limited resource scalability C) Environments with variable demand levels D) Environments with prepaid resource allocation

Answer: C) Environments with variable demand levels

8) What is the role of Neutron in the provisioning flow in OpenStack? A) Fetches information about the whole cluster from the database B) Publishes a message to the compute queue to trigger VM provisioning C) Configures IP, gateway, DNS name, and L2 connectivity. D) Contacts Cinder to get volume data

Answer: C) Configures IP, gateway, DNS name, and L2 connectivity.

9) How does the master node in the Google File System maintain communication with chunk servers? A) Command messages B) Update messages C) Query messages D) Heartbeat messages

Answer: D) Heartbeat messages

10) What does the ‘availability’ metric represent in the monitoring and auditing of SLAs? A) The speed at which a service responds B) The percentage of uptime for a service C) How often the service is available D) The ability for a resource to grow infinitely

Answer: B) The percentage of uptime for a service

More Weeks: Click here

Cloud Computing Nptel Week 3 Assignment Answers (Jan-Apr 2023 )

Q1. Which of the following is/are properties of Web Service SLAs? A. SLA automation is required for negotiation, provisioning, service delivery and monitoring. B. The QoS parameters are response time, SLA violation rate for reliability, availability and cost of service. C. UDDI (Universal Description Discovery and Integration) is used for resource allocation. D. The QoS parameters are related to security, privacy, trust, management, etc.

Answer: B, C

Q2. A task takes time T in a uniprocessor system. In a parallel implementation, the task runs on P processors parallelly. The parallel efficiency is Eff, where 0<Eff<1. What is the time taken by each processor (M) in this implementation? A. M=T B. M = T/(EffxP) C. M=T/P D. M=(TxEff)/P

Answer: B. M = T/(EffxP)

Q3. Row-oriented storage is optimal for transaction processing applications. A. True B. False

Answer: A. True

Q4. Which of the following is/are the SLA requirement(s) for PaaS cloud delivery model? A. Transparency B. Data Retention and Deletion C. Privacy D. Regulatory compliance

Answer: A, C, D

Q5. In a cloud, total service uptime is 175 minutes and availability of the service is 0.85. What is the service downtime? A. 55 minutes B. 148.75 minutes C. 26.25 minutes D. 45 minutes

Answer: C. 26.25 minutes

Q6. Which of the following database system/architecture follow(s) Quorum protocol for a large number of concurrent reads & writes? A. BigTable B. Dynamo C. Datastore D. Google File System (GFS)

Answer: B. Dynamo

Q7. Match the components of OpenStack with their functions. A. 1->B, 2->D, 3->A, 4->C B. 1->B, 2->A, 3->D, 4->C C. 1->C, 2->B, 3->D, 4->A D. 1->D, 2->A, 3->B, 4->C

Answer: D. 1->D, 2->A, 3->B, 4->C

Q8. Let D(t) and R(t) be the instantaneous demand and resources at time t respectively. If demand is exponential (D(t)=e’), any fixed provisioning interval (tp) according to the current demands will fall linearly behind. A. TRUE B. FALSE

Answer: B. FALSE

Q9. Which of the following statement(s) regarding OpenStack storage is/are wrong? A. Object storage is managed by Cinder B. Both ephemeral storage and block storage are accessible from within VM C. Block storage persists until VM is terminated D. Ephemeral storage is used to run operating system and/or scratch space

Answer: A, C

Q10. Statement 1: Multiple KPIs are aggregated to SLA. Statement 2: SLA contains SLO. A. Both statement 1 and 2 are correct B. Statement 1 is correct and statement 2 is incorrect C. Statement 2 is correct and statement 1 is incorrect D. Both statement 1 and 2 are incorrect

Answer: C. Statement 2 is correct and statement 1 is incorrect

Nptel Cloud Computing Week 3 Assignment Answers

All weeks of Cloud Computing: Click here

More NPTEL course: Click Here

Cloud Computing Nptel Week 3 Assignment Answers (July-Dec 2022 )

Course name: Cloud Computing NPTEL

Link to Enroll: Click Here

Q1. Which of the following is/are NOT SLA requirement(s) of PaaS cloud delivery model? a. Privacy b. Data Retention and Deletion c. Machine-Readable SLAs d. Certification

Answer: c. Machine-Readable SLAs

Q2. Which of the following is/are true regarding penalty cost? (Here D(t) and R(t) are instantaneous demand and resources at time t.) a. Penalty cost ox ID()/R()|dt b. If demand is flat, penalty is equal to 0. c. If demand is exponential (D(t)=e’), any fixed provisioning interval (tp) according to the current demands will fall linearly behind. d. The penalty cost for exponential demand is exponential.

Answer: b, d

Q3. Row-oriented storage is efficient for data-warehouse workloads. a. TRUE b. FALSE

Answer: b. FALSE

Q4. Which of the following is/are example(s) of cloud SLA(s) with IlaaS delivery model? a. Amazon EC2 b. Google App Engine c. Salesforce CRM d. Zoho mail

Answer: a. Amazon EC2

Q5. Which of the following OpenStack components is used for block storage services? a. Keystone b. Cinder c. Swift d. Neutron

Answer: b. Cinder

Q7. In Google File System (GFS), the master maintains regular communication with the chunk servers. a. TRUE b. FALSE

Answer: a. TRUE

Q8. In a system, 400 unit workloads have been added. What will be the penalty? a. 40% b. 100 % c. 20% d. 8000%

Answer: c. 20%

Q9. Which of the following option(s) is/are correct? a. Service Level Agreement(SLA) contains Service Level Objectives(SLO) b. Service Level Objectives(SLO) contains Service Level Agreement(SLA) c. Multiple Service Level Agreements (SLAs) are aggregated to Key Performance Indiocator (KPI) d. Key Performance Indiocators (KPIs) are aggregated to Service Level Objectives(SLO)

Answer: a, d

Q10. Statement 1: In OpenStack block storage, the stored objects persist until the VM is terminated.Statement 2: In OpenStack ephemeral storage, the stored objects are accessible from within VM as local file system. a. Both statement 1 and 2 are correct b. Statement 1 is correct and statement 2 is incorrect c. Statement 2 is correct and statement 1 is incorrect d. Both statement 1 and 2 are incorrect

image

The content uploaded on this website is for reference purposes only. Please do it yourself first.

IMAGES

  1. Assignment 3: Solutions

    assignment_3 solution

  2. Solution assignment 3 csc

    assignment_3 solution

  3. PPT

    assignment_3 solution

  4. Assignment 3 solution

    assignment_3 solution

  5. Assignment 3 Solution Updated

    assignment_3 solution

  6. ASSIGNMENT 3

    assignment_3 solution

COMMENTS

  1. fullstack-course4/assignments/assignment3/Assignment-3.md at ...

    Saved searches Use saved searches to filter your results more quickly

  2. NPTEL-Deep Learning (IIT Ropar)- Assignment 3 Solution (2024)

    NPTEL-Deep Learning (IIT Ropar)- Assignment 3 Solution (2024)Assignment-3 for Week-3 can be accessed from the following linkLink: https://onlinecourses.nptel...

  3. greyhatguy007/Machine-Learning-Specialization-Coursera

    Contains Solutions and Notes for the Machine Learning Specialization by Andrew NG on Coursera Note : If you would like to have a deeper understanding of the concepts by understanding all the math required, have a look at Mathematics for Machine Learning and Data Science

  4. Welcome to the NPTEL Assignment Answers 2024 repository by Progiez

    These files contain the assignment answers for each respective week. Select the Week File: Click on the file corresponding to the week you are interested in. For example, if you need answers for Week 3, open the week-03.md file. Review the Answers: Each week-XX.md file provides detailed solutions and explanations for that week's assignments ...

  5. TCSS 343 Assignment 3 Solutions

    TCSS 343 - Assignment 3. Version 1. April 9, 2021 1 GUIDELINES. ... TCSS 343 Assignment 3 Solutions. Course: Analysis and Design of Algorithms (TCSS 343) 6 Documents. Students shared 6 documents in this course. University: University of Washington. Info More info. Download. AI Quiz. AI Quiz.

  6. Introduction To Machine Learning Week 3 Assignment 3 Solution

    #machinelearning #nptel #swayam #python #ml Introduction To Machine Learning All week Assignment Solution - https://www.youtube.com/playlist?list=PL__28a0xFM...

  7. Coursera: Machine Learning (Week 3) [Assignment Solution]

    61. Logistic regression and apply it to two different datasets. I have recently completed the Machine Learning course from Coursera by Andrew NG. While doing the course we have to go through various quiz and assignments. Here, I am sharing my solutions for the weekly assignments throughout the course. These solutions are for reference only.

  8. PDF Assignment 3 Explanation

    Assignment 3 Explanation Introduction to Database Systems DataLab CS, NTHU. Modified/Added Classes •Parse -Lexer -Parser -QueryData •Algebra -ExplainPlan, ExplainScan -TablePlan, ProductPlan, SelectPlan etc •Planner -BasicQueryPlanner •An example of Experiment Results 2. Overview 3 createPlan()

  9. Introduction to Data Science in Python Assignment-3 · GitHub

    Also, make sure to exclude the footer and header information from the datafile. The first two columns are unneccessary, so you should get rid of them, and you should change the column labels so that the columns are: # Convert `Energy Supply` to gigajoules (there are 1,000,000 gigajoules in a petajoule). For all countries which have missing data ...

  10. NPTEL Assignment Answers 2024 And Solutions Progiez

    We provide you NPTEL Assignment Answers 2024 and solutions of all courses. Week 1,2,3, 4, 5, 6, 7 , 8, 9, 10 ,11, 1. By Swayam platform.

  11. Assignment 3 Solutions

    ASSIGNMENT - 3. Types of questions: MCQs - Multiple Choice Questions (a question has only one correct answer) MSQs - Multiple Select Questions (a question can have two, three or four correct options) In this case, equal weightage must be given to all options ... Assignment 3 Solutions. Course: Data analyatics with python (20MCA31) 21 ...

  12. Programming Assignment 3

    ##R Programming - Assignment 3 ####Coursera's Data Science Specialisation. ###Introduction. This repo contains the data and solutions for the final practical assignment in Coursera's R Programming course as part of Data Science Specialisation.

  13. NPTEL Advanced Computer Networks Week 3: Assignment 3 Solution #

    NPTEL Advanced Computer Networks Week 3: Assignment 3 Solution Follow the Study_Ease channel on WhatsApp:https://whatsapp.com/channel/0029VaL67ybFnSzAKMxdRa2...

  14. PDF assignment 3 solution

    ECE 5324/6324 Spring 2017 Assignment 3. 3.4-7 First check to see if the loop is indeed electromagnetically small. ≈ 10 MHz. ≈ 3×108 m/s. Yup. b ≈ 0.5 m. c λ = ≈ 30 m ≫ 2πb ≈ 3 m. You are welcome to use equation (3-53), but I don't like it, because it is one of these unit-specific formulas that do not appeal to my sense of ...

  15. Assignment 3 Solution Assignment 3 Solution

    Assignment 3 Solution Assignment 3 Solution Assignment 3 Solution 1 Assignment 3 Solution 1 dms 2030 individual assignment due date: 11:59 pm, april 30th total

  16. Programming in Java NPTEL Assignment Answers of Week 3 (2023)

    Programming Assignment Answers. Week 3 : Programming Assignment 1. Define a class Point with two fields x and y each of type double. Also, define a method distance (Point p1, Point p2) to calculate the distance between points p1 and p2 and return the value in double. Complete the code segment given below.

  17. PDF DBMS_IITM/Graded Assignments/GA Week03.pdf at main

    This repository contains solutions to the weekly assignments (2 & 3) of the Database Management Systems (DBMS) course offered by the Indian Institute of Technology Madras (IITM) as part of the Diploma in Programming program. Additionally, it also contains past OPPE solutions for the course. - DBMS_IITM/Graded Assignments/GA Week03.pdf at main · NebulaTris/DBMS_IITM

  18. TPTG620 Assignment 3 Solution 2024

    In this video, you are watching TPTG620 Assignment 3 Spring 2024 Solution by Tanveer Online Academy || TPTG620 Assignment 3 2024 || TPTG620 Assignment 3 solu...

  19. Programming in Java Nptel Week 3 Assignment Answers

    Solution: //Code. These are Programming in Java Nptel Week 3 Assignment Answers. Question 2. Define a class Point with two fields x and y each of type double. Also, define a method distance (Point p1, Point p2) to calculate the distance between points p1 and p2 and return the value in double. Solution:

  20. Cloud Computing Nptel Week 3 Assignment Answers

    These are Nptel Cloud Computing Week 3 Assignment 3 Answers Q5. What is the parallel efficiency (Eff) of an algorithm, when a task takes time T in uniprocessor system.

  21. amanchadha/stanford-cs224n-assignments-2021

    This assignment [notebook, PDF] has two parts which deal with representing words with dense vectors (i.e., word vectors or word embeddings).Word vectors are often used as a fundamental component for downstream NLP tasks, e.g. question answering, text generation, translation, etc., so it is important to build some intuitions as to their strengths and weaknesses.

  22. Solved This assignment will give you experience using

    This assignment will give you experience using SensorManager in Android Studio and help you understand its purpose. As you work with SensorManager, ask yourself when it would be effective to use in an application. Reference the readings in this module ' s Resources section for further details and help as you progress through this assignment.

  23. souraavv/NPTEL-DAA-Programming-Assignment-Solutions

    Request: Try these yourself till the deadline of assignment. Only after the deadline look for the solution. Else it won't help you in learning. The reason to put solution is to help after assignment deadline not during assignment. Sourav Sharma (UIIT Shimla) NPTEL-Design Analysis And Algorithm - Programming Assignments Solutions