Exemplo n.º 1
0
def test_c(flag, sql_flag):
    sql_dir = "./data/sql_test.csv"
    nor_dir = "./data/normal_test.csv"
    allm_dir = "./data/alltest_matrix.csv"
    if flag == '1' and sql_flag == '0':
        nor_matrix = generate(nor_dir, "./data/nor_matrix.csv", 0)
        return nor_matrix
    elif flag == '1' and sql_flag == '1':
        sql_matrix = generate(sql_dir, "./data/sqltest_matrix.csv", 1)
        return sql_matrix
    else:
        sql_matrix = generate(sql_dir, "./data/sqltest_matrix.csv", 1)
        nor_matrix = generate(nor_dir, "./data/nortest_matrix.csv", 0)
        df = pd.read_csv(sql_matrix)
        df.to_csv(allm_dir, encoding="utf_8_sig", index=False)
        df = pd.read_csv(nor_matrix)
        df.to_csv(allm_dir,
                  encoding="utf_8_sig",
                  index=False,
                  header=False,
                  mode='a+')
        return allm_dir
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 20 19:06:57 2017

@author: wf
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import metrics
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from featurepossess import generate
from sklearn.externals import joblib

sql_matrix = generate("./data/sqlnew.csv", "./data/sql_matrix.csv", 1)
nor_matrix = generate("./data/normal_less.csv", "./data/nor_matrix.csv", 0)

df = pd.read_csv(sql_matrix)
df.to_csv("./data/all_matrix.csv", encoding="utf_8_sig", index=False)
df = pd.read_csv(nor_matrix)
df.to_csv("./data/all_matrix.csv",
          encoding="utf_8_sig",
          index=False,
          header=False,
          mode='a+')

feature_max = pd.read_csv('./data/all_matrix.csv')
arr = feature_max.values
data = np.delete(arr, -1, axis=1)  #删除最后一列
#print(arr)