Question

In: Computer Science

Loading Pandas DataFrames and Creating Multiple Plots and Subplots x1 y1 y1_pred x2 y2 y2_pred x3...

Loading Pandas DataFrames and Creating Multiple Plots and Subplots
    x1     y1    y1_pred  x2    y2    y2_pred  x3     y3   y3_pred  x4     y4  y4_pred 
0   10   8.04   8.001000  10  9.14   8.000909  10   7.46  7.999727   8   6.58  7.001 
1    8   6.95   7.000818   8  8.14   7.000909   8   6.77  7.000273   8   5.76  7.001 
2   13   7.58   9.501273  13  8.74   9.500909  13  12.74  9.498909   8   7.71  7.001 
3    9   8.81   7.500909   9  8.77   7.500909   9   7.11  7.500000   8   8.84  7.001 
4   11   8.33   8.501091  11  9.26   8.500909  11   7.81  8.499455   8   8.47  7.001 
5   14   9.96  10.001364  14  8.10  10.000909  14   8.84  9.998636   8   7.04  7.001 
6    6   7.24   6.000636   6  6.13   6.000909   6   6.08  6.000818   8   5.25  7.001 
7    4   4.26   5.000455   4  3.10   5.000909   4   5.39  5.001364  19  12.50  12.500 
8   12  10.84   9.001182  12  9.13   9.000909  12   8.15  8.999182   8   5.56  7.001 
9    7   4.82   6.500727   7  7.26   6.500909   7   6.42  6.500545   8   7.91  7.001 
10   5   5.68   5.500545   5  4.74   5.500909   5   5.73  5.501091   8   6.89  7.001

Questions   

1 Calculate min and max for axis base of data in dataframe

2. Create a single plot of four scatter diagrams

3. Create a new visualization that combines the four previous plots in to one large plot with four subplots

Solutions

Expert Solution

In case of any queries, please revert back.

I guess you have loaded the dataset using pd.read_csv.

I will show you python codes for the following 3 questions. As the dataset cannot be copied, I wont be able to show the outputs, but the code will work once you load the dataset correctly.

1. We have 2 axis that are axis 1 and 0. Now, if the dataframe is stored in df, we can use min and max functions of pandas.

minVarX = df.min(axis=0)

This finds minimum horizontally

minVarY = df.min(axis=0)

This finds minimum vertically.

maxVarX = df.min(axis=0)

This finds maximum horizontally

maxVarY = df.min(axis=0)

This finds maximum vertically.

2. Now, we have to find scatter plots in the same diagram.

I will use matplotlib for this questions. :-

import matplotlib.pyplot as plt

fig, axs = plt.subplots(2,2)

axs[0, 0].scatter(x1, y1)
axs[0, 1].scatter(x2, y2)
axs[1, 0].scatter(x3, y3)
axs[1, 1].scatter(x4, y4)

3. Now we will create a master scatter plot with all datasets but of diferent colors :-

import matplotlib.pyplot as plt

fig, axs = plt.subplots(2,2)

plt.scatter(x1,y1, color='r')

plt.scatter(x2,y2, color='g')

plt.scatter(x3,y3, color='b')

plt.scatter(x4,y4, color='y')

plt.show()

If you face any problem, please revert back. I will solve it ASAP.


Related Solutions

Let X1,X2,X3 be i.i.d. N(0,1) random variables. Suppose Y1 = X1 + X2 + X3, Y2...
Let X1,X2,X3 be i.i.d. N(0,1) random variables. Suppose Y1 = X1 + X2 + X3, Y2 = X1 −X2, Y3 =X1 −X3. Find the joint pdf of Y = (Y1,Y2,Y3)′ using : Multivariate normal distribution properties.
1. Let ρ: R2 ×R2 →R be given by ρ((x1,y1),(x2,y2)) = |x1 −x2|+|y1 −y2|. (a) Prove...
1. Let ρ: R2 ×R2 →R be given by ρ((x1,y1),(x2,y2)) = |x1 −x2|+|y1 −y2|. (a) Prove that (R2,ρ) is a metric space. (b) In (R2,ρ), sketch the open ball with center (0,0) and radius 1. 2. Let {xn} be a sequence in a metric space (X,ρ). Prove that if xn → a and xn → b for some a,b ∈ X, then a = b. 3. (Optional) Let (C[a,b],ρ) be the metric space discussed in example 10.6 on page 344...
The parametric equations x = x1 + (x2 − x1)t,    y = y1 + (y2 − y1)t...
The parametric equations x = x1 + (x2 − x1)t,    y = y1 + (y2 − y1)t where 0 ≤ t ≤ 1 describe the line segment that joins the points P1(x1, y1) and P2(x2, y2). Use a graphing device to draw the triangle with vertices A(1, 1), B(4, 3), C(1, 6). Find the parametrization, including endpoints, and sketch to check. (Enter your answers as a comma-separated list of equations. Let x and y be in terms of t.)
We define a relation ∼ on R^2 by (x1,y1)∼(x2,y2) if and only if (y2−y1) ∈ 2Z....
We define a relation ∼ on R^2 by (x1,y1)∼(x2,y2) if and only if (y2−y1) ∈ 2Z. Show that the relation∼is an equivalence relation and describe the equivalence class of the point (0,1).
Let x,y ∈ R3 such that x = (x1,x2,x3) and y = (y1,y2,y3) determine if <x,y>=...
Let x,y ∈ R3 such that x = (x1,x2,x3) and y = (y1,y2,y3) determine if <x,y>= x1y1+2x2y2+3x3y3    is an inner product
Observation x1 y1 x2 y2 x3 y3 x4 y4 1 10 8.04 10 9.14 10 7.46...
Observation x1 y1 x2 y2 x3 y3 x4 y4 1 10 8.04 10 9.14 10 7.46 8 6.58 2 8 6.95 8 8.14 8 6.77 8 5.76 3 13 7.58 13 8.74 13 12.74 8 7.71 4 9 8.81 9 8.77 9 7.11 8 8.84 5 11 8.33 11 9.26 11 7.81 8 8.47 6 14 9.96 14 8.1 14 8.84 8 7.04 7 6 7.24 6 6.13 6 6.08 8 5.25 8 4 4.26 4 3.1 4 5.39 19...
Anscombe's Data Observation x1 y1 x2 y2 x3 y3 x4 y4 1 10 8.04 10 9.14...
Anscombe's Data Observation x1 y1 x2 y2 x3 y3 x4 y4 1 10 8.04 10 9.14 10 7.46 8 6.58 2 8 6.95 8 8.14 8 6.77 8 5.76 3 13 7.58 13 8.74 13 12.74 8 7.71 4 9 8.81 9 8.77 9 7.11 8 8.84 5 11 8.33 11 9.26 11 7.81 8 8.47 6 14 9.96 14 8.1 14 8.84 8 7.04 7 6 7.24 6 6.13 6 6.08 8 5.25 8 4 4.26 4 3.1 4...
Suppose that X1, X2, , Xm and Y1, Y2, , Yn are independent random samples, with...
Suppose that X1, X2, , Xm and Y1, Y2, , Yn are independent random samples, with the variables Xi normally distributed with mean μ1 and variance σ12 and the variables Yi normally distributed with mean μ2 and variance σ22. The difference between the sample means, X − Y, is then a linear combination of m + n normally distributed random variables and, by this theorem, is itself normally distributed. (a) Find E(X − Y). (b) Find V(X − Y). (c)...
Two identical loudspeakers are located at (x1, y1) = (0, 0) and (x2, y2) = (2.5...
Two identical loudspeakers are located at (x1, y1) = (0, 0) and (x2, y2) = (2.5 m,−0.5 m). The loudspeakers are driven by separate amplifiers, so that the loudspeakers are out of phase with each other, and produce sound waves with frequency of 650 Hz. The ambient temperature of air is 37 0C. A small microphone is moved along the y-axis. 1. At what distances along the y-axis will there be constructive interference? 2. At what distances along the y-axis...
The set R^2 with addition and scalar multiplication defined by (x1, y1) + (x2, y2) =...
The set R^2 with addition and scalar multiplication defined by (x1, y1) + (x2, y2) = (x1 + x2, y1 + y2) c(x1, y1) = (cx1, y1) is not a vector space. Determine which axiom fails and find a counterexample that shows that it fails.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT