Data science Study Notes 1. science Study Notes
Mutiple Plots on One Graphplt.plot(x, norm.pdf(x))plt.plot(x, norm.pdf(x, 1.0, 0.2)) #1.0 = mean, 0.2 = DSplt.show()
Use plt. savefig to save the image as blank:
Solution: Call plt. savefig before plt. show ().
Scatter Plot
From pylab import randnX = randn (10000) Y = randn (10000) plt. scatter (X, Y) # Pay Attention to the sequence. Draw a picture first and then add the axis axes = plt. axes () axes. set_xlim ([0, 1]) axes. set_ylim ([0, 4]) plt. show ()
Covariance: covariance
Covariance> 0: x, y changes in the same direction, and the greater the covariance, the higher the degree of the same direction.
Covariance <0: x, y reversely changes, and the greater the absolute value of the covariance, the higher the inverse degree.
Correlation calculation: covariance/SD
-1: perfect inverse correlation, 0: no correlation, 1: perfect correlation
Bayesian Formula
# Dictionary: calculates the number of users of different ages from numpy import randomrandom. seed (0) totals = {20:0, 30: 0, 40: 0, 50: 0, 60: 0, 70: 0} purchases = {20:0, 30: 0, 40: 0, 50: 0, 60: 0, 70: 0} totalPurchases = 0for _ in range (100000): age = random. choice ([20, 30, 40, 50, 60, 70]) purchaseProbability = float (age)/100.0 # division operation float totals [age] + = 1 if (random. random () <purchaseProbability): totalPurchases + = 1 purchases [age] + = 1