File:Svr epsilons demo.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (SVG file, nominally 900 × 450 pixels, file size: 65 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: SVR with different epsilons. The data was generated by normally perturbing a sine curve. The plot was prepared using scikit-learn.
Date
Source Own work
Author Shiyu Ji

Python Source Code

[edit]
# Note: the original version of this demo is in sklearn doc:
# http://scikit-learn.org/stable/auto_examples/gaussian_process/plot_compare_gpr_krr.html
# http://scikit-learn.org/stable/auto_examples/plot_kernel_ridge_regression.html
# Authors: Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>
# License: BSD 3 clause

import time

import numpy as np
import matplotlib
matplotlib.use('svg')
import matplotlib.pyplot as plt

from sklearn.svm import SVR
from sklearn.kernel_ridge import KernelRidge
from sklearn.model_selection import GridSearchCV
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import WhiteKernel, ExpSineSquared

rng = np.random.RandomState(0)

# Generate sample data
X = 15 * rng.rand(100, 1)
y = np.sin(X).ravel()
y[::2] += rng.normal(scale = 1.0, size = X.shape[0] // 2)  # add noise

# epsilon = 0.01
svr_e001 = SVR(kernel="rbf", epsilon=0.01, C=1)
svr_e001.fit(X, y)

# epsilon = 0.1
svr_e01 = SVR(kernel="rbf", epsilon=0.1, C=1)
svr_e01.fit(X, y)

# epsilon = 1.0
svr_e10 = SVR(kernel="rbf", epsilon=1.0, C=1)
svr_e10.fit(X, y)

# epsilon = 2.0
svr_e20 = SVR(kernel="rbf", epsilon=2.0, C=1)
svr_e20.fit(X, y)

X_plot = np.linspace(0, 20, 10000)[:, None]
# Predict using SVR
y_e001 = svr_e001.predict(X_plot)
y_e01 = svr_e01.predict(X_plot)
y_e10 = svr_e10.predict(X_plot)
y_e20 = svr_e20.predict(X_plot)

# Plot results
plt.figure(figsize=(10, 5))
lw = 2
plt.scatter(X, y, c='k', label='Data')
plt.plot(X_plot, np.sin(X_plot), color='navy', lw=lw, label='True')
plt.plot(X_plot, y_e001,color='brown', lw=lw, label = 'epsilon = 0.01')
plt.plot(X_plot, y_e01, color='turquoise', lw=lw,
         label='epsilon = 0.1')
plt.plot(X_plot, y_e10, color='orange', lw=lw,
         label='epsilon = 1.0')
plt.plot(X_plot, y_e20, color='red', lw=lw,
         label='epsilon = 2.0')
plt.xlabel('data')
plt.ylabel('target')
plt.xlim(0, 20)
plt.ylim(-3, 5)
plt.title('SVR (rbf kernel) with Different Epsilons')
plt.legend(loc="best",  scatterpoints=1, prop={'size': 8})

plt.savefig('svr_epsilons_demo.svg', format='svg')

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current19:57, 3 July 2017Thumbnail for version as of 19:57, 3 July 2017900 × 450 (65 KB)Shiyu Ji (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata