python


Importing images for manifold Isomap


There are 192 x 144 pixel images. They should be imported to a Python list so that the items in the list are NDArray instances. New dataframe should be created from the list and that dataframe should be given to Isomap. iso.fit(df) fails with the errors
array = array.astype(np.float64)
ValueError: setting an array element with a sequence.
I have spent more than one day trying to figure out how the NDArrays should be processed and the dataframe loaded with them. No luck. Any help would be appreciated.
import pandas as pd
from scipy import misc
import glob
from sklearn import manifold
samples = []
for filename in glob.glob('Datasets/ALOI/32/*.png'):
img = misc.imread(filename, mode='I')
samples.append(img)
df = pd.DataFrame.from_records(samples, coerce_float=True)
iso = manifold.Isomap(n_neighbors=6, n_components=3)
iso.fit(df)
If those are gray scale images from the ALOI, you probably want to treat each pixel's brightness as a feature. Therefore, you should flatten the img array with img.reshape(-1). The revised code follows:
import pandas as pd
from scipy import misc
import glob
from sklearn import manifold
samples = []
for filename in glob.glob('Datasets/ALOI/32/*.png'):
img = misc.imread(filename, mode='I')
# the following line changed
samples.append(img.reshape(-1))
df = pd.DataFrame.from_records(samples, coerce_float=True)
iso = manifold.Isomap(n_neighbors=6, n_components=3)
iso.fit(df)

Related Links

Matplotlib scroll_event not working with GTK3Agg backend
SELECT conditions on relations with SQLAlchemy
longest and shortest curves selected
Get the key with the maximum nested key in a python dictionary
Python fermat program only works for low numbers
How to create list of all parts of elements in NumPy array (Python list)
Encoding issue for Python tool Unidecode on CL
Accept only numbers on a python string [closed]
scrapy spider pass parameters
sending data to particular client from twisted server
Type Error, object cannot be interpreted as an index with tk message box bind commands
What is this condition testing? [duplicate]
Testing Flask login and authentication?
Pyjnius import jar file
Regex - Combining an 'or' with a 'look-behind'
Command fails in python, but not in terminal

Categories

HOME
google-apps-script
caching
meshlab
dynamics-crm
reverse-engineering
checkbox
ncurses
bower
jasmine
reportportal
wms
chaiscript
propertygrid
histogrammar
gspread
codeblocks
eval
structuremap
android-viewpager
cosmicmind
squarespace
cratedb
typeahead
eclipse-luna
scenebuilder
riak-ts
python-unicode
jcl
atlassian-plugin-sdk
jogl
zoho
mousewheel
aws-cognito
multiple-columns
sonarqube-msbuild-runner
flexboxgrid
plsqldeveloper
facebook4j
data-cleansing
java-ee-7
hash-collision
interrupt-handling
solidworks
encase
ipfw
freebase
pljson
recurrence-relation
polyfills
android-preferences
knockout-3.0
distributed-transactions
powermta
z3py
mouseclick-event
photography
react-native-fbsdk
launch
jszip
manifest.mf
chessboard.js
foxit
django-filer
distribute
inet
magento-1.4
spservices
android-recyclerview
js-cookie
crash-dumps
custom-url
searchkick
ticket-system
ctrlp
jcr-sql2
pisa
cpu-speed
errorprovider
method-overriding
bullet
indexing-service
mbox
openkinect
dynamic-proxy
visual-studio-addins
jquery-tabs
threadx
soa-suite
fraud-prevention
appfog
prng
fluidsynth
sametime
css-tables
sunspot-rails
cosm
curljs
printing-web-page
gtk2hs
server-error
mvccontrib-grid
graniteds
plinq
gears
writing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App