Upgrading to the dev version might be the better route, though.
On 04/01/2016 01:56 AM, Vincent Dubourg wrote:
Hi,
Manoj's tip only works if you are already using the 0.18dev version of
sklearn that brings a total refactoring of the gaussian_process submodule.
If you are still using the latest stable (aka 0.17), then custom
kernels can be specified as callable (simple Python function) using
the `corr` keyword argument.
From GaussianProcess' docstring (v0.17):
*corr* : string or callable, optional
A stationary autocorrelation function returning the
autocorrelation between two points x and x’. Default assumes a
squared-exponential autocorrelation model. Built-in
correlation models are:
'absolute_exponential', 'squared_exponential',
'generalized_exponential', 'cubic', 'linear'
Here is the code for the squared_exponential kernel:
def squared_exponential(theta, d):
"""
Squared exponential correlation model (Radial Basis Function).
(Infinitely differentiable stochastic process, very smooth)::
n
theta, dx --> r(theta, dx) = exp( sum - theta_i * (dx_i)^2 )
i = 1
Parameters
----------
theta : array_like
An array with shape 1 (isotropic) or n (anisotropic)
giving the
autocorrelation parameter(s).
dx : array_like
An array with shape (n_eval, n_features) giving the
componentwise
distances between locations x and x' at which the
correlation model
should be evaluated.
Returns
-------
r : array_like
An array with shape (n_eval, ) containing the values of the
autocorrelation model.
"""
theta = np.asarray(theta, dtype=np.float)
d = np.asarray(d, dtype=np.float)
if d.ndim > 1:
n_features = d.shape[1]
else:
n_features = 1
if theta.size == 1:
return np.exp(-theta[0] * np.sum(d ** 2, axis=1))
elif theta.size != n_features:
raise ValueError("Length of theta must be 1 or %s" %
n_features)
else:
return np.exp(-np.sum(theta.reshape(1, n_features) * d **
2, axis=1))
Implement the Pearson kernel like this and pass it to the
GaussianProcess estimator.
Cheers,
Vincent
2016-04-01 1:59 GMT+02:00 Manoj Kumar <manojkumarsivaraj...@gmail.com
<mailto:manojkumarsivaraj...@gmail.com>>:
Hi,
I remember seeing it somewhere but don't recall where exactly.
You can do it by the following.
1. Inherit from Kernel
(http://scikit-learn.org/dev/modules/generated/sklearn.gaussian_process.kernels.Kernel.html#sklearn.gaussian_process.kernels.Kernel)
2. Make your hyperparameters on the kernel an attribute starting
with `hyperparameter_` and make it an instance of Hyperparameter
as done here
(https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/gaussian_process/kernels.py#L1711)
3. Implement a __call__ that computes the kernel matrix and if
possible the gradient.
If not already present, this might be worth illustrating in an example
On Thu, Mar 31, 2016 at 7:45 PM, Sebastian Raschka
<se.rasc...@gmail.com <mailto:se.rasc...@gmail.com>> wrote:
Seems like that the GaussianProcess class only has an
autocorrelation parameter, but when I understand correctly,
the autocorrelation function is just the “normalized”
covariance kernel, thus it may be possible to provide custom
kernels here as well? If not, it may be interesting to
re-factor it a little bit and borrow the code from SVM to
accept custom kernels in Gaussian Processes as well?
> On Mar 31, 2016, at 5:17 PM, Andreas Mueller
<t3k...@gmail.com <mailto:t3k...@gmail.com>> wrote:
>
> Hi.
> What do you mean by Gaussian regression?
> You can specify your own kernels for SVMs, but it will be a
bit slower.
>
> Cheers,
> Andy
>
> On 03/28/2016 09:40 PM, Amita Misra wrote:
>> Hi,
>>
>> I was using weka earlier for support vector regression and
gaussian regression
>>
>> I am now switching to scikit and was trying to replicate my
results using support vector regression.
>> I could get similar results for poly and rbf kernel.
>>
>> Is there a way I can specify Pearson VII function
kernel(Puk Kernel) for support vector and Gaussian regression?
>>
>> Thanks,
>> Amita
>>
>>
>>
>> --
>> Amita Misra
>> Graduate Student Researcher
>> Natural Language and Dialogue Systems Lab
>> Baskin School of Engineering
>> University of California Santa Cruz
>>
>>
>>
>>
------------------------------------------------------------------------------
>> Transform Data into Opportunity.
>> Accelerate data analysis in your applications with
>> Intel Data Analytics Acceleration Library.
>> Click to learn more.
>>
>>
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
>>
>>
>> _______________________________________________
>> Scikit-learn-general mailing list
>>
>> Scikit-learn-general@lists.sourceforge.net
<mailto:Scikit-learn-general@lists.sourceforge.net>
>>
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
<mailto:Scikit-learn-general@lists.sourceforge.net>
>
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
<mailto:Scikit-learn-general@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
--
Manoj,
http://github.com/MechCoder
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
<mailto:Scikit-learn-general@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general