Python Forum
Classification by support vector method
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Classification by support vector method
#1
Classification by support vector method
Implement a method for solving the problem of classifying statistical data.
• visualize the initial data in the form of a scatter plot
• for a two-dimensional case with a linear separation of points, visualize the separating surface
• Display objects corresponding to the reference vectors.

So I realized a little but not all, help please
import matplotlib.pyplot as plt
all_in = []
file = open('iris.docx', 'r') #Edgar Anderson's Iris Data (Iris.scv)
file_tmp = [line.strip() for line in file]
file.close()
fer = ''
temp = ''
for i in range(len(file_tmp)):
   fer = file_tmp[i]
   for j in range(len(fer)):
       if j == (len(fer)-1):
           temp+=fer[j]
           all_in.append(temp)
           temp = ''
       elif fer[j] != ',':
           temp+=fer[j]
       elif fer[j] == ',':
           all_in.append(temp)
           temp = ''
   fer = ''
Sepal.Length = []
Sepal.Width = []
Petal.Length = []
Petal.Width= []
Species = []
while True:
   if all_in == []:
       break
   Sepal.Length.append(all_in[0])
   Sepal.Width.append(all_in[1])
   Petal.Length.append(all_in[2])
   Petal.Width.append(all_in[3])
   Species.append(all_in[4])
   all_in.pop(0)
   all_in.pop(0)
   all_in.pop(0)
   all_in.pop(0)
   all_in.pop(0)
   
for i in range(len(Sepal.Length)):
   temp = int(Sepal.Length[i])
   Sepal.Length.pop(i)
   Sepal.Length.insert(i, temp)
for i in range(len(Sepal.Width)):
   temp = int(Sepal.Length[i])
   Sepal.Width.pop(i)
   Sepal.Width.insert(i, temp)
for i in range(len(Petal.Length)):
   temp = int(Petal.Length[i])
   Petal.Length.pop(i)
   Petal.Length.insert(i, temp)
for i in range(len(Petal.Width)):
   temp = int(Petal.Width[i])
   Petal.Width.pop(i)
   Petal.Width.insert(i, temp)
for i in range(len(Species)):
   temp = int(Species[i])
   Species.pop(i)
   Species.insert(i, temp)

 
fig, ax = plt.subplots()
for color in ['red']:
   ax.scatter(Sepal.Length, Petal.Length, c=color, label=color,
              alpha=0.3, edgecolors='none')
ax.legend()
ax.grid(True)
plt.show()
Moderator sparkz_alot:
Added code tags and removed formatting
Reply
#2
If you are getting errors, please post them in their entirety between the error tags.

What is happening that you do not expect to be happening or what is not happening that you expect to be happening. Be more explicit on what you want help with.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  vector field plots Larssauerkraut 0 1,501 Oct-15-2019, 11:15 AM
Last Post: Larssauerkraut
  Class for Vector no_named_nobody 4 2,547 Oct-06-2019, 03:27 PM
Last Post: no_named_nobody
  How to correct the Python programming - Support Vector Machine vokoyo 7 4,363 Apr-06-2019, 10:11 AM
Last Post: scidam
  Divide a vector Langosmon 1 2,665 May-13-2018, 09:09 AM
Last Post: ThiefOfTime
  Bayesian Classification vokoyo 2 2,659 May-02-2018, 02:19 PM
Last Post: vokoyo
  vector sum of tuples roadrage 7 7,600 Nov-28-2016, 09:54 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020