def logistic_regression(self, input_file, output_file, true_labels, weights_file, total_epochs, learning_rate):
    simple_example = pd.read_csv(input_file, sep=',')
    social_features = simple_example[['follower_nbr', 'followee_nbr', 'tweets_nbr', 'avg_length_tweets']].values
    labels = pd.read_csv(true_labels, sep=',')
    true_labels = labels[['label']].values
    (X_train, X_test, y_train, y_test) = train_test_split(social_features, true_labels, test_size=0.2, random_state=45)
    n = social_features.shape[0]
    print('n=', n)
    print('true_labels', true_labels.shape[0])
    m = social_features.shape[1]
    (p_z_i_0, p_z_i_1) = self.init_probabilities(n)
    n_neurons = 3
    steps = 1
    hidden = False
    size_train = int((0.6 * n))
    classifier = self.define_nn(n_neurons, hidden, m, learning_rate)
    for i in range(total_epochs):
        (theta_i, eval_model, loss_and_metrics, weights) = self.lr_pzi(classifier, X_train, X_test, y_train, y_test, steps)
        result = pd.DataFrame(data=np.concatenate([np.where((theta_i > 0.5), 1, 0), y_test], axis=1), columns=['classification', 'truth'])
        np.savetxt(weights_file, weights, delimiter=',')
        result.to_csv(output_file)
        metrics = pd.DataFrame(np.array(eval_model).reshape(1, 1), columns=[['accuracy']])
        with open(output_file, 'a') as f:
            metrics.to_csv(f, header=True)
def logistic_regression(self, input_file, output_file, true_labels, weights_file, total_epochs, learning_rate):
    simple_example = pd.read_csv(input_file, sep=',')
    social_features = simple_example[['follower_nbr', 'followee_nbr', 'tweets_nbr', 'avg_length_tweets']].values
    labels = pd.read_csv(true_labels, sep=',')
    true_labels = labels[['label']].values
    (X_train, X_test, y_train, y_test) = train_test_split(social_features, true_labels, test_size=0.2, random_state=45)
    n = social_features.shape[0]
    print('n=', n)
    print('true_labels', true_labels.shape[0])
    m = social_features.shape[1]
    (p_z_i_0, p_z_i_1) = self.init_probabilities(n)
    n_neurons = 3
    steps = 1
    hidden = False
    size_train = int((0.6 * n))
    classifier = self.define_nn(n_neurons, hidden, m, learning_rate)
    for i in range(total_epochs):
        (theta_i, eval_model, loss_and_metrics, weights) = self.lr_pzi(classifier, X_train, X_test, y_train, y_test, steps)
        result = pd.DataFrame(data=np.concatenate([np.where((theta_i > 0.5), 1, 0), y_test], axis=1), columns=['classification', 'truth'])
        np.savetxt(weights_file, weights, delimiter=',')
        result.to_csv(output_file)
        metrics = pd.DataFrame(np.array(eval_model).reshape(1, 1), columns=[['accuracy']])
        with open(output_file, 'a') as f:
            metrics.to_csv(f, header=True)