mardi 22 octobre 2019

I want to do random sampling from a dataset using Bagging. And use that dataset in further analysis. How can I do that?

At first I want to do sampling in dataset using bagging. After that I will use back propagation algorithm for training and testing. Suppose I will select randomly 40% data from the dataset to create 1 sample set. After that I will take again 40% data form the total dataset and create another dataset.

Code for sampling:

def subsample(dataset, ratio):
    sample = list()
    n_sample = round(len(dataset) * ratio)
    while len(sample) < n_sample:
        index = randrange(len(dataset))
        append(dataset[index])
        print(sample)
    return sample

Dataset:(I will do sampling on 20 datasets from UCI Machine Repository)

import pandas as pd
dataset =pd.read_csv("abalone.csv")



Aucun commentaire:

Enregistrer un commentaire