Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Expected 2D array, got 1D array instead: #62

Open
BianTieyuan opened this issue May 15, 2024 · 13 comments
Open

ValueError: Expected 2D array, got 1D array instead: #62

BianTieyuan opened this issue May 15, 2024 · 13 comments

Comments

@BianTieyuan
Copy link

First I generate descriptors using asap gen_desc -f train.xyz soap

Then I tried to plot PCA map using asap map -f ASAP-desc.xyz -dm '[SOAP*]' -c energy pca . But it raise an error:
ValueError: Expected 2D array, got 1D array instead: array=[]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Did I miss something? I noticed that in ./examples/ice-phases there is a file named ice-properties.dat. Should I generate this file?

@BingqingCheng
Copy link
Owner

I think asap was not able to find the computed descriptors that match the pattern SOAP*.

Can you try:
asap map -f ASAP-desc.xyz -dm '[*]' -c energy pca

@BianTieyuan
Copy link
Author

Same error occurs:
ValueError: Expected 2D array, got 1D array instead: array=[]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

@BingqingCheng
Copy link
Owner

BingqingCheng commented May 15, 2024 via email

@BingqingCheng
Copy link
Owner

BingqingCheng commented May 15, 2024 via email

@BianTieyuan
Copy link
Author

Can you check the asapdesc.xyz to see if the descriptors are there?

On Tue, May 14, 2024 at 8:38 PM BIAN Tieyuan @.> wrote: Same error occurs: ValueError: Expected 2D array, got 1D array instead: array=[]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. — Reply to this email directly, view it on GitHub <#62 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABX4HLH777EXEL7LIAHEXWDZCLKCNAVCNFSM6AAAAABHXJSBZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJRGUYTSNJYHA . You are receiving this because you commented.Message ID: @.>

I think ASAP.desc.xyz has descriptors part
head ASAP-desc.xyz
324 Lattice="19.437355 0.0 0.0 0.0 19.608899 0.0 0.0 0.0 19.294381" Properties=species:S:1:pos:R:3:forces:R:3 virial="22.08496415278571 -11.07622265551594 -11.986055512090692 -11.07622265551594 35.14425376014253 16.63030124008082 -11.986055512090692 16.63030124008082 21.318629140356606" energy=-1506.23162973 SOAP-n4-l3-c3.9-g0.48="0.15065175542723358 0.41413572848936436 0.15442881904569383 0.39635378704700164 1.269596083363615 0.5118619375889054 1.4921384308189525 0.4028366684071485 0.7758510143819413 3.1035910867173286 0.003634057070103129 -0.0066250933568690025 0.026544311019918478 -0.014181185331135493 0.022433551085218148 0.003419745123305451 0.007050167594123492 0.4938056577831395 -0.15188154609397808 0.33010029535562885 0.006441775895658346 -0.013952767567860944 0.02210284893298129 -0.02847077854135643 0.038238163890281944 -0.01578249917668867 0.07025764433710256 0.21774395294409518 -0.05630440073751578 0.6637604329984965 0.00475774675898043 -0.008333583233294287 0.022552685495556456 -0.020739855929913283 0.018612311366640193 -0.021435842905358733 0.039121660368157146 0.19480903064166177 -0.08529378132378014 0.4413009790840278 0.03319205794402811 0.0884136810480686 0.061368320605293805 0.037644259621189835 0.2398197306867688 0.16904873995559397 0.09390317343016366 0.2134160523826052 0.13721401636198025 0.2775739217062056 6.603579629441512e-05 -0.0002739156591809482 0.00012542008254162382 -0.0017320095324621925 0.002460033444293402 0.0030152387663000334 -0.0034497069514447423 0.1106706838917041 0.0659363161445587 0.2894990449137697 0.00012682314586821643 -0.00019710732986006127 0.0017411394704301734 -0.0020117303641952835 0.0015067695608470624 0.004012971145400304 0.005345027400553524 0.07901811374483193 0.03440507991158534 0.2457701569807339 0.00012266372634987008 -0.00017260626395685015 0.001410726920555865 -0.002264794686534974 0.0007061193499517245 0.0010153495339550187 0.005647825258665105 0.040566250384631734 0.006202168909829222 0.17391461604330266 0.06443650163831621 0.17338348278768623 0.08431926869835893 0.0937318088378108 0.5174688645984549 0.2972598638620704 0.3596441867723391 0.35008960838107367 0.42965785320303207 0.7924787888649556 0.001183021052081881 -0.004836283474274908 -0.004087717509448744 -0.017491260448943894 0.026714339123648213 0.049787058939192795 0.08045173146343088 0.21873223708294437 0.1481829783240068 0.4209390222687386 0.001610845081931847 -0.003781278413217762 0.005348820912541725 -0.011929726064927967 0.016762623554133407 0.020468678756127297 0.04790903955537106 0.18103819445490982 0.08242300235638272 0.276048512027836 0.001563577152140688 -0.0029562433804480774 0.007336312479960288 -0.008968264849687073 0.008095413272871468 -0.001705029090411112 0.025631668175063703 0.10605738687789884 0.020091332052973334 0.17512171440268043 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.09803271970121327 0.261393170607818 0.19758068967174877 0.12541096937050897 0.7281164983432776 0.49701615378110237 0.3774888553790882 0.42790507523392257 0.20968051574547794 0.2229767084162806 0.0009080244305422551 -0.0019083420852802145 0.0044340235350913025 -0.004561000481207977 0.004011830871243956 -0.009296572280767352 0.009534006078011322 0.022528133560591256 -0.02413715403626434 0.02691183976846562 0.0009265944516952108 -0.0017566302247691875 0.0037588772041779192 -0.004273397592089731 0.0033310176507897462 -0.007110152884325432 0.008055242414299522 0.01590017844092615 -0.019031492259529405 0.024177207836622614 0.0020087142442710222 -0.0038242651910205365 0.007172372112411881 -0.00807687004150116 0.007281053964987163 -0.013657500552190937 0.015379846540436391 0.02607787663609942 -0.030228145470109984 0.036675700886514916 0.03304681463881189 0.08758698611508779 0.06665850152865246 0.04217056383760473 0.23713776406198941 0.17235119204170235 0.11693791004161876 0.1390804016502791 0.07962827171816224 0.06677258638515125 0.00016645422588714586 -0.0003649000423342814 0.0007503051360085961 -0.0005412040270863524 0.0008480819536872338 -0.001680741474501637 0.0005739029751768039 0.004203287708163459 -0.0021813704753751275 0.009879538441399258 0.000872685865334532 -0.0016642169633457656 0.0030826901754763356 -0.0027153455654166394 0.003186496415015292 -0.0058697594914885924 0.004912901521472577 0.01147271352702262 -0.009078531410248324 0.015629361990533566 0.00044073169737306097 -0.0008396732942388452 0.001484046386558018 -0.0013769983868818687 0.0016033640339236813 -0.002816338184228855 0.002534197124295871 0.005331888458444074 -0.004270787518257197 0.009340517305391415" pbc="T T T" C 3.36076008 4.62705993 2.93737000 -2.44304555 -9.03136253 1.35526976 C 10.54029994 3.07547992 2.35338003 -0.02384790 0.06162597 -0.26169757 C 15.66280007 3.86764002 2.69455003 -0.85709150 -1.23413871 -0.28359857 C 2.39065005 10.37470001 2.13691000 0.20105988 -0.77445762 1.20316864 C 10.28249997 10.26839997 2.70232991 -0.69207662 -2.27570002 0.48650206 C 15.47160005 9.08644005 3.18919004 -0.45333300 1.19713786 -0.34983932 C 2.54553992 16.01369992 3.77300000 1.06474092 0.72640307 -0.59857102 C 9.68334000 16.42149992 2.67514007 0.28889155 -0.15340140 -0.70375203

@BianTieyuan
Copy link
Author

And does the xyz file contains multiple frames? If it only has one frame it doesn’t make sense to do pca on global descriptors.

On Tue, May 14, 2024 at 8:40 PM Bingqing Cheng @.> wrote: Can you check the asapdesc.xyz to see if the descriptors are there? On Tue, May 14, 2024 at 8:38 PM BIAN Tieyuan @.> wrote: > Same error occurs: > ValueError: Expected 2D array, got 1D array instead: array=[]. Reshape > your data either using array.reshape(-1, 1) if your data has a single > feature or array.reshape(1, -1) if it contains a single sample. > > — > Reply to this email directly, view it on GitHub > <#62 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABX4HLH777EXEL7LIAHEXWDZCLKCNAVCNFSM6AAAAABHXJSBZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJRGUYTSNJYHA > . > You are receiving this because you commented.Message ID: > @.***> >

Yes it has multiple frames. It shows 728 frames after loading it into OVITO.

@Ericwang6
Copy link

I am having the same problem...

@BingqingCheng
Copy link
Owner

BingqingCheng commented May 18, 2024 via email

@BianTieyuan
Copy link
Author

test.zip
Here is a .exyz file containing 31 frames. Thanks!

@BingqingCheng
Copy link
Owner

BingqingCheng commented May 19, 2024 via email

@BianTieyuan
Copy link
Author

It is very strange that I used the same command asap map -f ASAP-desc.xyz -dm '[*]' pca but still has error
ValueError: Expected 2D array, got 1D array instead: array=[]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
I installed asaplib by pip install asaplib.

@BingqingCheng
Copy link
Owner

BingqingCheng commented May 20, 2024 via email

@BianTieyuan
Copy link
Author

Still same error. I paste the whole error message here:

(MDA2) [polyucmp@localhost 282ab895-d12b-4248-8357-261397bf73a6]$ asap map -f ASAP-desc.xyz -dm [*]  pca
load xyz file:  ASAP-desc.xyz , a total of  31 frames , a total of  10360 atoms , with elements:  [1, 6, 7, 53, 82] .
Find the following descriptor names that match the specifications:  ['SOAP-n4-l3-c3.9-g0.48']
Cannot find the specified descriptors from xyz
0
Remove raw desciptors..
removing the global descriptors from output xyz with the names:  ['SOAP-n4-l3-c3.9-g0.48']
removing the atomic descriptors from output xyz with the names:  []
Perform standard scaling of the design matrix. To turn it off use `--no-scale`
Using PCA ...
Start PCA for a design matrix with shape  (0,)
Traceback (most recent call last):
  File "/run/media/polyucmp/282ab895-d12b-4248-8357-261397bf73a6/software/anaconda3/envs/MDA2/bin/asap", line 8, in <module>
    sys.exit(asap())
...

    raise ValueError(msg)
ValueError: Expected 2D array, got 1D array instead:
array=[].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants