mirror of
https://github.com/RustyRaptor/learnopencv.git
synced 2026-12-03 22:15:16 -07:00
clean up SVM code
This commit is contained in:
1 parent
65aee4ede9
commit
6cbf4d5222
9 files changed
+5
-3
No files matched your search
File renamed without changes.
File renamed without changes.
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 334 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 448 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 145 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 253 KiB |
File renamed without changes.
File renamed without changes.
+5
-3
@@ -1,20 +1,22 @@
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn import svm
|
||||
from sklearn.cross_validation import train_test_split
|
||||
from sklearn.model_selection import train_test_split
|
||||
import numpy as np
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.append(os.path.abspath("../../"))
|
||||
sys.path.append(os.path.abspath("../"))
|
||||
from utils import read_data, plot_data, plot_decision_function
|
||||
|
||||
# Read data
|
||||
x, labels = read_data("../points_rightside.txt", "../points_leftside.txt")
|
||||
x, labels = read_data("points_class_0.txt", "points_class_1.txt")
|
||||
|
||||
# Split data to train and test on 80-20 ratio
|
||||
X_train, X_test, y_train, y_test = train_test_split(x, labels, test_size = 0.2, random_state=0)
|
||||
|
||||
# Plot traning and test data
|
||||
plot_data(X_train, y_train, X_test, y_test)
|
||||
|
||||
|
||||
# Create a linear SVM classifier
|
||||
clf = svm.SVC(C = 1.0, kernel='linear')
|
||||
Reference in new issue
Block a user