generated from LufsX/Experiment-LogReg
This commit is contained in:
+2
-2
@@ -32,7 +32,7 @@ def sigmoid(intX):
|
|||||||
return 1.0 / (1 + np.exp(-intX))
|
return 1.0 / (1 + np.exp(-intX))
|
||||||
|
|
||||||
|
|
||||||
def stocGradAscent1(X, y, numIter=150):
|
def train_logreg(X, y, numIter=150):
|
||||||
m, n = X.shape
|
m, n = X.shape
|
||||||
weights = np.ones(n)
|
weights = np.ones(n)
|
||||||
for j in range(numIter):
|
for j in range(numIter):
|
||||||
@@ -84,7 +84,7 @@ def accuracy(X, y, weights):
|
|||||||
def colicTest():
|
def colicTest():
|
||||||
X_train, y_train = load_data("./horse-colic.data")
|
X_train, y_train = load_data("./horse-colic.data")
|
||||||
X_test, y_test = load_data("./horse-colic.test")
|
X_test, y_test = load_data("./horse-colic.test")
|
||||||
trainWeights = stocGradAscent1(X_train, y_train, 500)
|
trainWeights = train_logreg(X_train, y_train, 500)
|
||||||
errorCount = 0
|
errorCount = 0
|
||||||
numTestVec = 0.0
|
numTestVec = 0.0
|
||||||
for x, true_label in zip(X_test, y_test):
|
for x, true_label in zip(X_test, y_test):
|
||||||
|
|||||||
Reference in New Issue
Block a user