原创 7.7 迴歸中的相關度的實現

import numpy as np import math def computeCorrelation(x,y): xBar=np.mean(x) yBar=np.mean(y) SSR,varX,varY=

原创 8.3 聚類(Clustering) hierarchical clustering 層次聚類

假設有N個待聚類的樣本,對於層次聚類來說,步驟: 1、(初始化)把每個樣本歸爲一類,計算每兩個類之間的距離,也就是樣本與樣本之間的相似度; 2、尋找各個類之間最近的兩個類,把他們歸爲一類(這樣類的總數就少了

原创 8.2 聚類(Clustering) K-means算法應用

1.python實現kmean 算法 import numpy as np def kmeans(X,k,maxIt): numPoints,numDim=X.shape dataSet=np.zeros((numPo

原创 8.1 聚類(Clustering) K-means算法

歸類: 聚類(clustering) 屬於非監督學習 (unsupervised learning) 無類別標記(class label) 舉例: K-means 算法: 3.1 Clustering

原创 7.6 迴歸中的相關度和R平方值

皮爾遜相關係數 (Pearson Correlation Coefficient): 1.1 衡量兩個值線性相關強度的量 1.2 取值範圍 [-1, 1]: 正向相關: >0,

原创 7.6 非線性迴歸算法應用

Python 實現: import numpy as np import random #m demoted the number of examples here,not the number of feature def gr

原创 LeetCode 121 Best Time to Buy and Sell Stock I

1)題目: Say you have an array for which the ith element is the price of a given stock on day i.

原创 8.4 聚類(Clustering) hierarchical clustering 層次聚類應用

python實現: from numpy import * class cluster_node: def __init__(self,vec,left=None,right=None,distance=0.0,id=Non

原创 7.4 多元線性迴歸應用

例子 一家快遞公司送貨:X1: 運輸里程 X2: 運輸次數 Y:總運輸時間 目的,求出b0, b1,…. bp: y_hat=b0+b1x1+b2x2+ … +bpxp Python代碼: from numpy

原创 7.5 非線性迴歸算法

概率: 1.1 定義 概率(P)robability: 對一件事情發生的可能性的衡量 1.2 範圍 0 <= P <= 1 1.3 計算方法: 1.3.1 根據個人置信 1.3.2 根據歷史