2

If I run this code, I get a memory error. Does anyone know what I can improve?

Code:

import numpy as np import matplotlib.pyplot as plt from sklearn import datasets from sklearn.gaussian_process import GaussianProcessClassifier from sklearn.gaussian_process.kernels import RBF import cv2 input = "testProbe.jpg" # load the image, convert it to grayscale image = cv2.imread(input) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # threshold the image to reveal light regions in the gray image thresh = cv2.threshold(gray, 145, 200, cv2.THRESH_BINARY)[1] # import data X = np.where(thresh>0) xx = np.array(X) xx = np.ravel(xx,order='F') zz = xx.reshape((int(len(xx)/2),2)) y = np.asarray(np.zeros((widthX, 1), dtype=int)) 

Here I edit y to play with the data and get a second dataset.

y[1:5] = 1 

And when I run this code, the error appears:

gpc_rbf_isotropic = GaussianProcessClassifier().fit(zz, y) 
2
  • what is the size of your dataset? Commented Aug 1, 2018 at 9:06
  • @GabrielM the size is 338742 Commented Aug 1, 2018 at 10:35

1 Answer 1

2

GaussianProcessClassifier()

has the following parameter as stated in the docs:

copy_X_train : bool, optional (default: True)

if you set it to false it will save you a lot of memory.

However, GaussianProcessClassifier consumes a lot of memory even for fairly small datasets. I would recommend you to use a different classifier where you can apply some dimensionality reduction techniques.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer. Unfortunately, it didn't help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.