Skip to main content

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1plt.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1plt.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')
plt.ylabel('y')
plt.xlabel('x')
plt.show()

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')
plt.ylabel('y')
plt.xlabel('x')
plt.show()

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

plt.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
plt.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')
plt.ylabel('y')
plt.xlabel('x')
plt.show()
Corrected a spelling error in 2nd to the last tine of code from "idx_1" to "idx_0". Also added labels
Source Link
Djib2011
  • 8k
  • 5
  • 28
  • 38

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)
import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')

plt.ylabel('y') plt.xlabel('x') plt.show()

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')
plt.ylabel('y')
plt.xlabel('x')
plt.show()

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')

plt.ylabel('y') plt.xlabel('x') plt.show()

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')
plt.ylabel('y')
plt.xlabel('x')
plt.show()
Corrected a spelling error in 2nd to the last tine of code from "idx_1" to "idx_0". Also added labels
Source Link

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_1]iloc[idx_0].y, s=10, c='r', marker="o", label='second')
plt.show()

plt.ylabel('y') plt.xlabel('x') plt.show()

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_1].y, s=10, c='r', marker="o", label='second')
plt.show()

Let's assume that the name of your dependent variable column is "target", and you have stored the data in "dataset" variable. You can segregate the dataset based on value of target in following way:

import numpy as np    
idx_1 = np.where(dataset.target == 1)
idx_0 = np.where(dataset.target == 0)

The above code with return indices of dataset with target values 0 and 1.

Now, to display the data, use:

ax1.scatter(dataset.iloc[idx_1].x, dataset.iloc[idx_1].y, s=10, c='b', marker="o", label='first')
ax1.scatter(dataset.iloc[idx_0].x, dataset.iloc[idx_0].y, s=10, c='r', marker="o", label='second')

plt.ylabel('y') plt.xlabel('x') plt.show()

Source Link
Loading