Week4

Linear regression

gradient,intercept,r_value, p_value, 
stderr=scipy.stats.linregress(x,y)

Polynomial regression

np.polynomial.polynomial.polyfit
c,stats=nppp.polyfit(x,y,degree,full=True, w=None)
nppp.polyval(datasample,c)

Clustering: kmeans/kmeans2

centroids,var=scipy.cluster.vq.kmeans(Dataset, Number_of_Clusters)
id,dis=scipy.cluster.vq.vq(Dataset, centroids)
np.random.multivariate_normal([10,0],[[3,1],[1,4]]),size=[100,1])

Exercise

1-. Import the ‘Auto Insurance in Sweden’ dataset from the following url, and do a linear regression to fit the data. Plot the data and the regression line.

url: https://www.math.muni.cz/~kolacek/docs/frvs/M7222/data/AutoInsurSweden.txt

2 - Download the ‘IRIS’ dataset from the url below, import it to Python and do a 3-mean clustering based on the inputs (4-dimesnion). Plot the members of each cluster with different colour (Red, Blue & Green ) in a 2-axis coordinate which the horizontal axis is the first input and the vertical one is second input.

url: https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data

Last updated

Was this helpful?