I'm using Scikit-learn for tSNE to interrogate around 1000 scatterplots, but I appear to require a 2D numpy array to access the fit_transform method. I'm new to Python.
My code,
from sklearn.manifold import TSNE
import numpy as np
import cv2
mypath='/Path/to/files/scatterplots/'
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
photos = np.empty(len(onlyfiles), dtype=object)
for n in range(0, len(onlyfiles)):
photos[n] = cv2.imread( join(mypath,onlyfiles[n]) )
fig, axes = plt.subplots(2, 2, figsize=(10,10), subplot_kw={'xticks':(), 'yticks':()})
for ax, img in zip(axes.ravel(), photos):
ax.imshow(img)
Problem code
tsne = TSNE(random_state=50)
digits_tsne = tsne.fit_transform (photos.data)
Error
ValueError Traceback (most recent call last) in
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/manifold/t_sne.py in fit_transform(self, X, y)
892 Embedding of the training data in low-dimensional space.
893 """
--> 894 embedding = self._fit(X)
- 3 further lines of error output within t_sne.py
I believe the fit_transform method requires a 2D numpy array, e.g.
'target': array([0, 1, 2, 3])
where 0-3 refer to the different data (parasites) behind each of the scatterplots 1-4.
Request How do I combine the target array into image numpy array so fit_transform can see it and process it?

photos.data?fit_transform()with a single image. I'm guessing that that image should have a 2D shape.