File:Svr epsilons demo.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

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

Summary

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

# 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

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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

3 July 2017

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 JiUser created page with UploadWizard
The following pages on the English Wikipedia use this file (pages on other projects are not listed):

Global file usage

The following other wikis use this file:

Metadata