# -*- coding: utf-8 -*- """ Created on Sun Aug 06 15:57:18 2017 @author: mdz """ '''http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=9162199&id=4223505''' import numpy as np #读取数据 def loadDataSet(): dataList=[]
function a alpha = 0.0001; [m,n] = size(q1x); max_iters = 500; X = [ones(size(q1x,1),1), q1x]; % append col of ones for intercept term theta = zeros(n+1, 1); % initialize theta for k = 1:max_iters hx = 1./(1+exp(-X*theta)); theta = theta + alpha * X'
利用TensorFlow实现多元逻辑回归,代码如下: import tensorflow as tf import numpy as np from sklearn.linear_model import LogisticRegression from sklearn import preprocessing # Read x and y x_data = np.loadtxt("ex4x.dat").astype(np.float32) y_data = np.loadtxt(&qu