Question: in Python using Numpy Randomly flipping some of the examples from positive to negative, and from negative to positive. assume you have the following dataset
in Python using Numpy
Randomly flipping some of the examples from positive to negative, and from negative to positive.
assume you have the following dataset ( assume data is 100 elements ) where the first column is x and second column is y and the third column is (0 or 1), 1 means the point is positive and 0 means the point is negative
the question is:
Write a function that randomly flips some of the examples from positive to negative, and from negative to positive with following noise (flipping) rates: 10%, 20%, 30%, 40%, and 50%

I wrote this but I want to flip random points based on the percentage
import numpy as np
def flipping(data,percentage):
data = np.genfromtxt('my_data1.csv', delimiter=',') c1 = data[:,0] c2= data[:,1] c3= data[:,2]
3 C 2 3 1 1 1 1 1 1 1 5 6 3 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 1 A 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.2 0.2 0.2 0.2 0.2 0.2 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.2 1 1 B 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 0.96 1 1 1 1 1 1 20 1 21 1 1 1 22 23 24 25 1 0.2 1 1 1 26 27 28 29 0.2 0.2 0.2 0.24 1 0.96 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
