當前位置:首頁 » 分析預測 » logistic回歸分析股票python
擴展閱讀
重慶上市公司股票葯 2024-10-09 11:02:04

logistic回歸分析股票python

發布時間: 2021-05-09 15:04:54

㈠ logistic回歸分析結果解讀

可以使用在線spss平台SPSSAU進行分析,格式更加易理解,分析結果如下:

第一:對模型整體情況進行說明,比如對R方值進行描述,以及列出模型公式。

第二:逐一分析X對於Y(相對於的對比項)影響情況;如果X對應的P值小於0.05則說明X會對Y(相對於的對比項)產生影響關系,此時可結合OR值進一步分析影響幅度。第三:總結分析結果。

以及可結合輸出的智能文字分析,進行解讀。

㈡ 您好,請問Python運行二元logistics回歸怎樣設置對照呢

邏輯回歸裡面像男女這種類別類型的特徵,都要轉換成兩個特徵,如果是男,就是01,如果是女,就是10。你說的啞變數,也就是大家常說的獨熱編碼,在sklearn里有onehotencoder,可以去查查怎麼用。拿著個男女屬性被轉化成獨熱編碼以後,通過邏輯回歸,可以算出那個特徵的權重。

㈢ 機器學習中,使用邏輯回歸(python)做二分類時,recall,f1_score,support的含義是

假設預測目標為0和1
數據中1的個數為a,預測1的次數為b,預測1命中的次數為c
准確率 precision = c / b
召回率 recall = c / a
f1_score = 2 * precision * recall / (precision + recall)

㈣ logistic回歸分析

如果沒有因果關系 你做回歸出來又有想解釋什麼?
單因素是一元自變數的 多因素是多元自變數吧。

㈤ 怎麼用python做logistic回歸

Logistic回歸主要分為三類,一種是因變數為二分類得logistic回歸,這種回歸叫做二項logistic回歸,一種是因變數為無序多分類得logistic回歸,比如傾向於選擇哪種產品,這種回歸叫做多項logistic回歸。還有一種是因變數為有序多分類的logistic回...

㈥ 怎麼看python中邏輯回歸輸出的解釋

以下為python代碼,由於訓練數據比較少,這邊使用了批處理梯度下降法,沒有使用增量梯度下降法。

##author:lijiayan##data:2016/10/27
##name:logReg.pyfrom numpy import *import matplotlib.pyplot as pltdef loadData(filename):
data = loadtxt(filename)
m,n = data.shape print 'the number of examples:',m print 'the number of features:',n-1 x = data[:,0:n-1]
y = data[:,n-1:n] return x,y#the sigmoid functiondef sigmoid(z): return 1.0 / (1 + exp(-z))#the cost functiondef costfunction(y,h):
y = array(y)
h = array(h)
J = sum(y*log(h))+sum((1-y)*log(1-h)) return J# the batch gradient descent algrithmdef gradescent(x,y):
m,n = shape(x) #m: number of training example; n: number of features x = c_[ones(m),x] #add x0 x = mat(x) # to matrix y = mat(y)
a = 0.0000025 # learning rate maxcycle = 4000 theta = zeros((n+1,1)) #initial theta J = [] for i in range(maxcycle):
h = sigmoid(x*theta)
theta = theta + a * (x.T)*(y-h)
cost = costfunction(y,h)
J.append(cost)

plt.plot(J)
plt.show() return theta,cost#the stochastic gradient descent (m should be large,if you want the result is good)def stocGraddescent(x,y):
m,n = shape(x) #m: number of training example; n: number of features x = c_[ones(m),x] #add x0 x = mat(x) # to matrix y = mat(y)
a = 0.01 # learning rate theta = ones((n+1,1)) #initial theta J = [] for i in range(m):
h = sigmoid(x[i]*theta)
theta = theta + a * x[i].transpose()*(y[i]-h)
cost = costfunction(y,h)
J.append(cost)
plt.plot(J)
plt.show() return theta,cost#plot the decision boundarydef plotbestfit(x,y,theta):
plt.plot(x[:,0:1][where(y==1)],x[:,1:2][where(y==1)],'ro')
plt.plot(x[:,0:1][where(y!=1)],x[:,1:2][where(y!=1)],'bx')
x1= arange(-4,4,0.1)
x2 =(-float(theta[0])-float(theta[1])*x1) /float(theta[2])

plt.plot(x1,x2)
plt.xlabel('x1')
plt.ylabel(('x2'))
plt.show()def classifyVector(inX,theta):
prob = sigmoid((inX*theta).sum(1)) return where(prob >= 0.5, 1, 0)def accuracy(x, y, theta):
m = shape(y)[0]
x = c_[ones(m),x]
y_p = classifyVector(x,theta)
accuracy = sum(y_p==y)/float(m) return accuracy

調用上面代碼:

from logReg import *
x,y = loadData("horseColicTraining.txt")
theta,cost = gradescent(x,y)print 'J:',cost

ac_train = accuracy(x, y, theta)print 'accuracy of the training examples:', ac_train

x_test,y_test = loadData('horseColicTest.txt')
ac_test = accuracy(x_test, y_test, theta)print 'accuracy of the test examples:', ac_test

學習速率=0.0000025,迭代次數=4000時的結果:

似然函數走勢(J = sum(y*log(h))+sum((1-y)*log(1-h))),似然函數是求最大值,一般是要穩定了才算最好。

從上面這個例子,我們可以看到對特徵進行歸一化操作的重要性。

㈦ logistic回歸分析 數據需要多少

一、正確得做法是把所有變數代如回歸方程,逐步回歸分析,必要是多用幾種篩選變數得技術,同時要考慮因素得交互作用,綜合分析」 二、單因素分析的結果和多因素分析的結果不一樣是很正常的事情,因為單因素分析往往存在混雜因素的影響 三、要明白在建立多元回歸模型之前,單因素分析的主要作用是起到篩選的作用,通常選取p小於0.一或者0.二的因素進入多元回歸模型,而多元回歸模型中偏回歸系數有意義才是真正的有意義; 如果多元回歸模型中偏回歸系數沒有意義,就算單因素有意義也是沒有意義的

㈧ 怎麼看邏輯回歸的python代碼

你把大於0,改成大於等於0,再重新試試。 另外你的邏輯弄得復雜了,好好想想,把邏輯簡化一下。

如果你會畫狀態圖,可以畫個圖給自己看看,好多邏輯是重復的。

比如if H3MRRFlag == 1: 象這樣的語句是一需要的,直接刪除。因為從python語法角度看,可能會有runtime error, 因為你沒有初始化變數