The data arrays (x, y) currently in the memory are organized so that all data points...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The data arrays (x, y) currently in the memory are organized so that all data points with a given label (e.g. 'Setosa') lie in a contiguous part of the arrays (X, y). In this question we will check the impact of changing the order of the data on the number of iterations required to learn a correct perceptron. The commented code below needs a small change in order to generate a random shuffle (permutation) of the data. Please look up the particular functions of the code, see how they work and then do the required modification and uncomment/evaluate the code. [74] # establish a random shuffle s = np.arange (10) [ ] S # np.random.shuffle(s) # shuffle sample # X_shuffle = X[s]; #y_shuffle = y[s]; array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) Modify the code below as follows: (i) Pick a sufficiently small n so that convergences takes 20 iterations or more. (ii) Add an extra line that fits the perceptron on the shuffled data. (iii) Plot the error for both training processes (the original data and the shuffled data). What do you observe? ppn.fit (x, y) plt.plot(range (1, len(ppn.errors_) +1), ppn.errors, marker='0) plt.xlabel('Epochs') plt.ylabel('Number of updates') # plt.savefig('images/02_07.png', dpi=300) plt.show() Give your answers here. [ ] ppn = Perceptron(eta=0.0001, n_iter=20, random_state=1) ppn.fit (x, y) plt.plot(range (1, len(ppn.errors_) + 1), ppn.errors, marker='o') plt.xlabel('Epochs') plt.ylabel('Number of updates') plt.show() The data arrays (x, y) currently in the memory are organized so that all data points with a given label (e.g. 'Setosa') lie in a contiguous part of the arrays (X, y). In this question we will check the impact of changing the order of the data on the number of iterations required to learn a correct perceptron. The commented code below needs a small change in order to generate a random shuffle (permutation) of the data. Please look up the particular functions of the code, see how they work and then do the required modification and uncomment/evaluate the code. [74] # establish a random shuffle s = np.arange (10) [ ] S # np.random.shuffle(s) # shuffle sample # X_shuffle = X[s]; #y_shuffle = y[s]; array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) Modify the code below as follows: (i) Pick a sufficiently small n so that convergences takes 20 iterations or more. (ii) Add an extra line that fits the perceptron on the shuffled data. (iii) Plot the error for both training processes (the original data and the shuffled data). What do you observe? ppn.fit (x, y) plt.plot(range (1, len(ppn.errors_) +1), ppn.errors, marker='0) plt.xlabel('Epochs') plt.ylabel('Number of updates') # plt.savefig('images/02_07.png', dpi=300) plt.show() Give your answers here. [ ] ppn = Perceptron(eta=0.0001, n_iter=20, random_state=1) ppn.fit (x, y) plt.plot(range (1, len(ppn.errors_) + 1), ppn.errors, marker='o') plt.xlabel('Epochs') plt.ylabel('Number of updates') plt.show()
Expert Answer:
Related Book For
Supply Chain Network Design Applying Optimization and Analytics to the Global Supply Chain
ISBN: 978-0133017373
1st edition
Authors: Michael Watson, Sara Lewis, Peter Cacioppi, Jay Jayaraman
Posted Date:
Students also viewed these programming questions
-
answer all questions as instructed below. attend all questions. 4 Computer Vision (a) Explain why such a tiny number of 2D Gabor wavelets as shown in this sequence are so efficient at representing...
-
Stenback Exercise Equipment, Inc. reported the following financial statements for 2016: Requirements 1. Compute the amount of Stenback Exercises acquisition of plant assets. Assume the acquisition...
-
Markham Leather, a distributor of leather products, uses the FIFO method for valuing inventories. It began August with 50 units of an inventory item that cost $160 each. During August, the store...
-
In a study of facial behavior, people in a control group are timed for eye contact in a 5-minute period. Their times are normally distributed with a mean of 184.0 seconds and a standard deviation of...
-
Describe multiple interfaces and explain why or when they are needed.
-
Dunlop Company makes a product that it sells for $200. Dunlop incurs annual fixed costs of $250,000 and variable costs of $160 per unit. Required The following requirements are interdependent. For...
-
Please answer the following questions. 1. Complete the table below using Accounting Equation (Assets Liabilities + Owner's Equity): Compute the missing amounts in the accounting equation for each...
-
In 2022, Leo construction will work on a residential project that lasts 4 months. The direct costs of the residential project are shown in the following bar chart. $160,000 A 1 $120,000 B 2 $90,000 C...
-
Which of the following are types of segmentation genes? a. Gap genes b. Pair-rule genes c. Segment-polarity genes d. All of the above are types of segmentation genes.
-
Which form of HIV RNA is packaged into HIV particles? a. Fully spliced RNA b. Incompletely spliced RNA c. Unspliced RNA d. All three forms of RNA are packaged into HIV particles.
-
A mammalian embryo that is XY but is missing the SRY gene would be expected to develop into a. a male. b. a female. c. a hermaphrodite. d. none of the above because sex differentiation would not...
-
Positional information may provide a cue for a cell to a. divide. b. migrate. c. differentiate. d. undergo apoptosis. e. do any of the above.
-
Molecules that convey positional information include a. diffusible morphogens. b. cell adhesion molecules. c. ATP. d. both a and b.
-
1. In April 2020, the Canadian economy lost about 2 million jobs amid the Covid-19 crisis. According to Statistics Canada, the unemployment rate soared to 13%, up from the 7.8% recorded in March of...
-
a. Determine the domain and range of the following functions.b. Graph each function using a graphing utility. Be sure to experiment with the window and orientation to give the best perspective of the...
-
A popular online shoe retailer has been successfully servicing their customers across the United States with the most popular brands of shoes from tennis shoes to high heels for the past five years....
-
Brazil Model: Open the file Brazil Capacity.zip. This is the same model as highlighted in the case. Additional information and directions are in this file. For this assignment, go to the scenario...
-
You are starting a network design study for a company that wants to reduce costs in its distribution network. Their financial year is the same as the calendar year. Last May, the company changed...
-
What uses of the word reserve might be found in practice in various parts of the world?
-
In most countries, interest expense is: A. Taxable. B. Not tax-deductible. C. Tax-deductible. D. Not relevant for tax.
-
Under which countrys national accounting system is there the closest link between accounting and tax? A. Norway. B. Denmark. C. Germany. D. The UK.
Study smarter with the SolutionInn App