예제 #1
0
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X,
                                                    y,
                                                    test_size=0.25,
                                                    random_state=0)

# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

# Fitting classifier to the Training set
from sklearn.svm import SVM
classifier = SVM(kernel='rbf', random_state=0)
classifier.fit(X_train, y_train)

# Predicting the Test set results
y_pred = classifier.predict(X_test)

# Making the Confusion Matrix
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)

# Visualising the Training set results
from matplotlib.colors import ListedColormap
X_set, y_set = X_train, y_train
X1, X2 = np.meshgrid(
    np.arange(start=X_set[:, 0].min() - 1,
              stop=X_set[:, 0].max() + 1,
              step=0.01),
예제 #2
0
for i in range(len(x)):

    N = 2803 - len(x[0])

    t1 = np.pad(x[0], (0, N), 'median')

    X.append(t1)

svm = SVM()

X = np.array(X)

X = np.squeeze(X)

model = svm.fit(X, Y)

accuracy = []

final_result = []

for i in range(len(testing_set)):

    temp = preprocessor(Folders[1], testing_set[i])

    N = 2803 - len(temp)

    temp_1 = np.array(temp).reshape(1, len(temp))

    temp_2 = np.pad(temp_1[0], (0, N), 'median')