def LeaveUserFeaturesHour(): X_train, X_test, y_train, y_test = data.Train_test_split() predict = MLP_model(X_train, X_test, y_train, y_test) y_test = y_test.reshape(1, -1)[0] Evaluation.evalution(y_test, predict) Evaluation.AUC(y_test, predict)
def pca(): X_train, X_test, y_train, y_test = data.Train_test_split() pca = PCA(n_components=100) X_train = pca.fit(X_train).transform(X_train) pca1 = PCA(n_components=100) X_test = pca1.fit(X_test).transform(X_test) return X_train, X_test, y_train, y_test
temp = np.ones(x.shape[0] + 1) temp[0:-1] = x a = temp for l in range(0, len(self.weights)): a = self.activation(np.dot(a, self.weights[l])) return a ''' [2,2,1] 第一个2:表示 数据的纬度,因为是二维的,表示两个神经元,所以是2 第二个2:隐藏层数据纬度也是2,表示两个神经元 1:表示输入为一个神经元 tanh:表示用双曲函数里的tanh函数 ''' print("--------DNN---------") X_train, X_test, y_train, y_test = data.Train_test_split() nn = NeuralNetwork([100,2,1], 'tanh') #X = np.array([[0, 0,0], [0, 1,0], [1, 0,0], [1, 1,0]]) #y = np.array([0, 1, 1, 0]) nn.fit(X_train, y_train) predict = [] for i in X_test: if nn.predict(i)[0] < 0 :predict.append(0) else:predict.append(1) #print(i,nn.predict(i)) y_test = y_test.reshape(1,-1)[0] Evaluation.evalution(y_test,predict) Evaluation.AUC(y_test,predict)