import os
from dataSet import DataSet

arquivo = open("saidaaa.csv", 'w')
arquivo.write("CHAMOU PARTITION")
arquivo.close()

dts = DataSet()

print("Iniciando particionamento....")
arquivo = open("saidaaa.csv", 'a')
arquivo.write("Iniciando particionamento....A")
arquivo.close()
#pasta pra salvar

#dts.setFilePath("../../Bases/MachineLearningCVE/teste/")
dts.setFilePath("../../Bases/MachineLearningCVE/DoS_56att2/")

#caminho e nome do arquivo
#dts.setFileName("../../Bases/MachineLearningCVE/teste_ddos_BINARY.csv")
dts.setFileName(
    "../../Bases/MachineLearningCVE/Friday-WorkingHours-Afternoon-DDos_BINARY_56att.pcap_ISCX.csv"
)
print("chamando load")
arquivo = open("saidaaa.csv", 'a')
arquivo.write("chamando load...A")
arquivo.close()
dts.loadData(10)
Exemplo n.º 2
0
from evaluate_module import EvaluateModule

dts = DataSet()
dts.setFilePath("bases/gstav_first_attempt/")
dts.setFileName("testes/base_iris.csv")
#dts.setFileName("SmallTrainingSet.csv")
#dts.setFileName("winequality-red.csv")
#dts.setFileName("NSL_KDD-master/20PercentTrainingSet.csv")
#dts.setFileName("NSL_KDD-master/KDDTrain+binary_class.csv")
#dts.setFileName("NSL_KDD-master/SmallTrainingSet.csv")
#dts.setFileName("NSL_KDD-master/SmallTrainingSetFiveClass.csv")
#dts.setFileName("../../KDDCUP99/kddcup10%.csv")


#print("load data")
dts.loadData(6)



'''
#CONFIGURACAO DO KNN
knn = KnnModule()
knn.setKNeighbors(1)
knn_classifier = KnnClassifier()
knn_classifier.setKnn(knn)

#CONFIGURACAO DA REDE NEURAL
rna = RnaModule()
rna.setNumberNeuronsImputLayer(41)
rna.setActivationFunctionImputLayer("tanh")
rna.setImputDimNeurons(41)
    folds = []
    for indexes in splitter.split(x, y):
        folds.append(pd.DataFrame(dataset.values[indexes[1], ], columns=names))

    return folds


def writeFoldToCsv(fold, foldIndex, destinationPath):
    fold.to_csv(destinationPath + "fold_" + str(foldIndex) + ".csv",
                index=False)


dts = DataSet()
dts.setFilePath("../cicids2017/10-folds/")
dts.setFileName("../cicids2017/total_selectedFeatures.csv")
dts.loadData()

directory = os.path.dirname(dts.file_path)
if not os.path.exists(directory):
    os.makedirs(directory)

dataset = dts.dataframe_data_set

classFeatureName = dataset.columns[len(dataset.columns) - 1]

#removing all instances that have no class value
dataset = dts.dataframe_data_set.dropna(subset=[classFeatureName])

dataset = binarizeDataset(dataset, classFeatureName)

folds = splitDataset(dataset, classFeatureName, 10)