<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=Support_Vector_Machine</id>
	<title>Support Vector Machine - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=Support_Vector_Machine"/>
	<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Support_Vector_Machine&amp;action=history"/>
	<updated>2026-06-16T21:07:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=Support_Vector_Machine&amp;diff=407&amp;oldid=prev</id>
		<title>Davrot at 17:17, 17 October 2025</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Support_Vector_Machine&amp;diff=407&amp;oldid=prev"/>
		<updated>2025-10-17T17:17:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:17, 17 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Top ==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff:1.41:old-292:rev-407:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=Support_Vector_Machine&amp;diff=292&amp;oldid=prev</id>
		<title>Davrot: Created page with &quot;== Top == Questions to [mailto:davrot@uni-bremen.de David Rotermund]  == [https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html sklearn.svm.SVC] == &lt;syntaxhighlight lang=&quot;python&quot;&gt;sklearn.svm.SVC(*, C=1.0, kernel=&#039;rbf&#039;, degree=3, gamma=&#039;scale&#039;, coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape=&#039;ovr&#039;, break_ties=False, random_state=None)&lt;/syntaxhighlight&gt;&lt;blockquo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Support_Vector_Machine&amp;diff=292&amp;oldid=prev"/>
		<updated>2025-10-17T15:36:51Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Top == Questions to [mailto:davrot@uni-bremen.de David Rotermund]  == [https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html sklearn.svm.SVC] == &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;sklearn.svm.SVC(*, C=1.0, kernel=&amp;#039;rbf&amp;#039;, degree=3, gamma=&amp;#039;scale&amp;#039;, coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape=&amp;#039;ovr&amp;#039;, break_ties=False, random_state=None)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Top ==&lt;br /&gt;
Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;br /&gt;
&lt;br /&gt;
== [https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html sklearn.svm.SVC] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;sklearn.svm.SVC(*, C=1.0, kernel=&amp;#039;rbf&amp;#039;, degree=3, gamma=&amp;#039;scale&amp;#039;, coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape=&amp;#039;ovr&amp;#039;, break_ties=False, random_state=None)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;&amp;#039;&amp;#039;&amp;#039;kernel&amp;#039;&amp;#039;&amp;#039;: {‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’} or callable, default=’rbf’&lt;br /&gt;
&lt;br /&gt;
Specifies the kernel type to be used in the algorithm. If none is given, ‘rbf’ will be used. If a callable is given it is used to pre-compute the kernel matrix from data matrices; that matrix should be an array of shape (n_samples, n_samples).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC.fit fit] ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;fit(X, y, sample_weight=None)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Fit the SVM model according to the given training data.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;X&amp;#039;&amp;#039;&amp;#039;: {array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples)&lt;br /&gt;
&lt;br /&gt;
Training vectors, where n_samples is the number of samples and n_features is the number of features. For kernel=”precomputed”, the expected shape of X is (n_samples, n_samples).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;y&amp;#039;&amp;#039;&amp;#039;: array-like of shape (n_samples,)&lt;br /&gt;
&lt;br /&gt;
Target values (class labels in classification, real numbers in regression).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC.predict predict] ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;predict(X)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;For an one-class model, +1 or -1 is returned.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;X&amp;#039;&amp;#039;&amp;#039;: {array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples_test, n_samples_train)&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;y_pred&amp;#039;&amp;#039;&amp;#039;: ndarray of shape (n_samples,)&lt;br /&gt;
&lt;br /&gt;
Class labels for samples in X.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test and train data ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
rng = np.random.default_rng(1)&lt;br /&gt;
&lt;br /&gt;
a_x: np.ndarray = rng.normal(1.5, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
a_y: np.ndarray = rng.normal(3.0, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
data_train_0: np.ndarray = np.concatenate((a_x, a_y), axis=-1)&lt;br /&gt;
class_train_0: np.ndarray = np.full((data_train_0.shape[0],), -1)&lt;br /&gt;
&lt;br /&gt;
a_x = rng.normal(1.5, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
a_y = rng.normal(3.0, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
data_test_0: np.ndarray = np.concatenate((a_x, a_y), axis=-1)&lt;br /&gt;
class_test_0: np.ndarray = np.full((data_test_0.shape[0],), -1)&lt;br /&gt;
del a_x&lt;br /&gt;
del a_y&lt;br /&gt;
&lt;br /&gt;
a_x = rng.normal(0.0, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
a_y = rng.normal(0.0, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
data_train_1: np.ndarray = np.concatenate((a_x, a_y), axis=-1)&lt;br /&gt;
class_train_1: np.ndarray = np.full((data_train_0.shape[0],), +1)&lt;br /&gt;
&lt;br /&gt;
a_x = rng.normal(0.0, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
a_y = rng.normal(0.0, 1.0, size=(1000))[:, np.newaxis]&lt;br /&gt;
data_test_1: np.ndarray = np.concatenate((a_x, a_y), axis=-1)&lt;br /&gt;
class_test_1: np.ndarray = np.full((data_test_0.shape[0],), +1)&lt;br /&gt;
del a_x&lt;br /&gt;
del a_y&lt;br /&gt;
&lt;br /&gt;
data_train: np.ndarray = np.concatenate((data_train_0, data_train_1), axis=0)&lt;br /&gt;
data_test: np.ndarray = np.concatenate((data_test_0, data_test_1), axis=0)&lt;br /&gt;
label_train: np.ndarray = np.concatenate((class_train_0, class_train_1), axis=0)&lt;br /&gt;
label_test: np.ndarray = np.concatenate((class_test_0, class_test_1), axis=0)&lt;br /&gt;
&lt;br /&gt;
np.save(&amp;quot;data_train.npy&amp;quot;, data_train)&lt;br /&gt;
np.save(&amp;quot;data_test.npy&amp;quot;, data_test)&lt;br /&gt;
np.save(&amp;quot;label_train.npy&amp;quot;, label_train)&lt;br /&gt;
np.save(&amp;quot;label_test.npy&amp;quot;, label_test)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Train and test ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
import sklearn.svm  # type:ignore&lt;br /&gt;
&lt;br /&gt;
data_train = np.load(&amp;quot;data_train.npy&amp;quot;)&lt;br /&gt;
data_test = np.load(&amp;quot;data_test.npy&amp;quot;)&lt;br /&gt;
label_train = np.load(&amp;quot;label_train.npy&amp;quot;)&lt;br /&gt;
label_test = np.load(&amp;quot;label_test.npy&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
svm = sklearn.svm.SVC()&lt;br /&gt;
&lt;br /&gt;
svm.fit(X=data_train, y=label_train)&lt;br /&gt;
prediction = svm.predict(X=data_test)&lt;br /&gt;
&lt;br /&gt;
performance = 100.0 * (prediction == label_test).sum() / prediction.shape[0]&lt;br /&gt;
&lt;br /&gt;
print(f&amp;quot;Performance correct: {performance}%&amp;quot;) # -&amp;gt; Performance correct: 95.4%&amp;lt;/syntaxhighlight&amp;gt;Sometimes it is useful to scale the value range of the individual features to the same range:&amp;lt;pre class=&amp;quot;pythonv&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
import sklearn.svm  # type:ignore&lt;br /&gt;
&lt;br /&gt;
data_train = np.load(&amp;amp;quot;data_train.npy&amp;amp;quot;)&lt;br /&gt;
data_test = np.load(&amp;amp;quot;data_test.npy&amp;amp;quot;)&lt;br /&gt;
label_train = np.load(&amp;amp;quot;label_train.npy&amp;amp;quot;)&lt;br /&gt;
label_test = np.load(&amp;amp;quot;label_test.npy&amp;amp;quot;)&lt;br /&gt;
&lt;br /&gt;
svm = sklearn.svm.SVC()&lt;br /&gt;
&lt;br /&gt;
min_value = data_train.min(axis=0, keepdims=True)&lt;br /&gt;
data_train -= min_value&lt;br /&gt;
data_test -= min_value&lt;br /&gt;
&lt;br /&gt;
min_value = data_train.max(axis=0, keepdims=True)&lt;br /&gt;
data_train /= min_value&lt;br /&gt;
data_test /= min_value&lt;br /&gt;
&lt;br /&gt;
svm.fit(X=data_train, y=label_train)&lt;br /&gt;
prediction = svm.predict(X=data_test)&lt;br /&gt;
&lt;br /&gt;
performance = 100.0 * (prediction == label_test).sum() / prediction.shape[0]&lt;br /&gt;
&lt;br /&gt;
print(f&amp;amp;quot;Performance correct: {performance}%&amp;amp;quot;)&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
</feed>