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

PCA returns all 0's #293

Open
danthegoodman1 opened this issue Apr 26, 2024 · 5 comments
Open

PCA returns all 0's #293

danthegoodman1 opened this issue Apr 26, 2024 · 5 comments

Comments

@danthegoodman1
Copy link

Using with a 1536 vector, I get [0, 0, 0] printed out from a single row.

Example code:

package main

import (
	"fmt"
	"github.com/sjwhitworth/golearn/pca"
	"gonum.org/v1/gonum/mat"
)

func main() {
	embeddings := mat.NewDense(1, 1536, []float64{
		0.0051681744,
		0.017187592,
		-0.018685209,
		-0.01855924,
		-0.04725188,
		-0.030288232,
		0.027670903,
		0.0036775568,
		0.011253114,
		0.0064068567,
		-0.0016953152,
		0.015801948,
		-0.0013007914,
		-0.007872981,
		0.059904635,
		0.050247114,
		-0.027516942,
		0.009923455,
		-0.04039364,
		0.050051164,
		-0.00042557836,
		0.030232247,
		-0.01368849,
		0.032919556,
		0.017299563,
		0.016795693,
		-0.0017548,
		0.02043476,
		0.04078554,
		-0.03770633,
		-0.026117302,
		-0.049995176,
		0.024185797,
		-0.055257827,
		-0.03224773,
		0.04235314,
		0.06466342,
		0.014724224,
		-0.015647987,
		-0.041401383,
		0.022198306,
		0.007341117,
		0.04495647,
		0.007106677,
		-0.024087822,
		0.05240256,
		-0.020084849,
		-0.03224773,
		0.01622184,
		0.046412095,
		0.0237799,
		-0.018867161,
		-0.005353627,
		0.04397672,
		-0.006172417,
		0.0073271208,
		-0.014948166,
		0.072669365,
		-0.0054865927,
		-0.037678335,
		0.016081875,
		0.034263212,
		0.0071101766,
		-0.004748282,
		-0.026677158,
		0.028944576,
		-0.038546115,
		0.023206048,
		-0.0051436806,
		0.011903947,
		0.025515456,
		-0.014612253,
		-0.01111315,
		0.0038000254,
		0.0006403358,
		-0.023262033,
		-0.016291821,
		-0.0043703793,
		0.020714687,
		-0.004202422,
		0.040253676,
		-0.0028360228,
		-0.0253475,
		-0.020168828,
		-0.048203636,
		0.020658702,
		-0.07558062,
		0.02795083,
		-0.01707562,
		0.008299871,
		-0.018335298,
		-0.012064906,
		-0.022590207,
		-0.0070751854,
		-0.015885925,
		0.0055530756,
		-0.0327516,
		0.0041149445,
		-0.0058504995,
		-0.038462136,
		0.047111917,
		-0.012036913,
		-0.020056857,
		0.002643572,
		-0.031547908,
		0.011134145,
		0.011952935,
		-0.0024266276,
		-0.046803996,
		-0.021316532,
		-0.08532212,
		0.007229146,
		0.0062354007,
		0.020602716,
		0.001294668,
		0.004223417,
		0.06886234,
		-0.014514278,
		0.021722429,
		-0.022646192,
		0.025291514,
		-0.0028272748,
		0.031827837,
		-0.056909405,
		0.0036705586,
		-0.041009482,
		0.0056370543,
		-0.03555088,
		-0.037958264,
		0.0154660335,
		0.02124655,
		-0.048567545,
		-0.0111761335,
		-0.009342604,
		-0.05021912,
		-0.007124173,
		-0.04585224,
		0.041233424,
		-0.030512175,
		0.04268905,
		-0.015410048,
		-0.02975637,
		-0.0033188988,
		-0.011617021,
		-0.02464768,
		-0.018321302,
		-0.03227572,
		-0.006140925,
		-0.024269776,
		0.0187132,
		-0.035578877,
		0.034795076,
		-0.06634299,
		0.03401128,
		0.027069058,
		-0.013898435,
		0.02620128,
		-0.024451729,
		-0.044424605,
		0.0047342856,
		-0.021778414,
		-0.057077363,
		-0.0049932194,
		0.013464547,
		-0.033479415,
		-0.0460202,
		0.03790228,
		0.024353754,
		-0.0436688,
		0.023276031,
		-0.013114637,
		-0.041009482,
		-0.049267363,
		-0.0054620993,
		-0.008705767,
		0.042129196,
		0.021232555,
		-0.010077415,
		-0.021400511,
		0.048343603,
		0.021064598,
		0.04050561,
		0.008215893,
		-0.008698769,
		-0.004118444,
		-0.0066657905,
		0.03692253,
		0.02296811,
		0.008103922,
		-0.013268597,
		0.007949961,
		-0.005794514,
		0.019441014,
		0.0011319597,
		-0.01925906,
		0.02074268,
		0.03434719,
		-0.013639502,
		0.039917763,
		0.06662291,
		0.03594278,
		0.06359969,
		-0.024591694,
		-0.0050701997,
		-0.08577,
		-0.028832605,
		-0.044704534,
		0.015130119,
		0.013184618,
		0.026117302,
		0.09120061,
		-0.019566981,
		-0.0093286075,
		-0.019902896,
		-0.050331093,
		-0.037930273,
		0.0034816072,
		0.019315047,
		0.012344834,
		-0.061080337,
		-0.018307304,
		0.029448448,
		0.060072593,
		0.024983592,
		0.028468698,
		0.0072221477,
		0.025235528,
		0.022254292,
		-0.0032034284,
		0.036054753,
		0.037762314,
		-0.026859112,
		0.009580543,
		-0.03770633,
		0.023332017,
		0.015158112,
		0.00032213613,
		-0.010287361,
		0.021400511,
		0.019273058,
		-0.07182958,
		-0.025389489,
		0.080339395,
		0.04574027,
		0.020000871,
		-0.015703972,
		-0.024045832,
		-0.027209021,
		0.026117302,
		0.036054753,
		0.021820404,
		0.015759958,
		0.02054673,
		-0.0035708342,
		0.025935348,
		-0.017439527,
		-0.02054673,
		0.031016046,
		0.04781174,
		-0.04198923,
		-0.033283465,
		-0.03423522,
		-0.037734322,
		-0.0024948602,
		-0.0041744295,
		-0.00039343035,
		0.025151549,
		0.0038595102,
		-0.00045007208,
		-0.038378157,
		-0.042213175,
		-0.0046468084,
		0.028090796,
		0.04086952,
		-0.033115506,
		0.06617503,
		-0.010875211,
		-0.02054673,
		-0.002920001,
		0.019636964,
		-0.042633064,
		0.011288105,
		0.010812227,
		-0.018615225,
		-0.029028555,
		-0.021680439,
		0.028370723,
		-0.0030652138,
		0.009804485,
		0.021064598,
		0.0027835362,
		-0.032415688,
		0.022422248,
		-0.008341861,
		-0.027041065,
		0.038546115,
		-0.018041372,
		0.024241783,
		0.013401563,
		0.05240256,
		0.030344218,
		0.053774208,
		0.004538336,
		0.0027275505,
		-0.02460569,
		0.01746752,
		0.033983283,
		-0.023206048,
		0.04436862,
		-0.013940425,
		0.015494026,
		-0.027558932,
		-0.004377377,
		-0.03462712,
		-0.07513273,
		-0.010455319,
		0.06343173,
		0.02194637,
		-0.041009482,
		-0.051954675,
		0.0526265,
		-0.019524993,
		0.041513354,
		-0.0064663417,
		0.0051226863,
		0.042885,
		0.05299041,
		0.015773954,
		0.014486285,
		-0.010462317,
		0.017915405,
		-0.07233345,
		0.02639723,
		-0.016123865,
		0.0026260766,
		-0.012183875,
		0.0011485805,
		0.020280799,
		0.04047762,
		0.046300124,
		-0.0057420274,
		-0.023639938,
		0.0151161235,
		0.008824737,
		-0.006760266,
		-0.032919556,
		-0.035158984,
		0.047895715,
		0.006441848,
		0.011631017,
		0.0070751854,
		0.028258752,
		0.027362982,
		-0.041905254,
		0.0436688,
		-0.080731295,
		-0.019832913,
		0.011770981,
		0.009125659,
		0.008376852,
		-0.024507714,
		-0.011337092,
		0.017985387,
		0.0061304276,
		-0.009769495,
		0.048147652,
		-0.020378774,
		-0.0030547166,
		0.042325146,
		-0.025375493,
		-0.004205921,
		0.0036250702,
		0.022856139,
		0.0130306585,
		-0.051254854,
		0.0028272748,
		-0.03373135,
		0.041121453,
		0.030960059,
		0.0073271208,
		-0.031687874,
		0.027069058,
		-0.041793283,
		-0.016291821,
		0.025921352,
		-0.008432837,
		0.0068407455,
		0.02823076,
		-0.037986256,
		0.0097485,
		0.031687874,
		0.014094385,
		-0.0146542415,
		0.028608663,
		-0.048007686,
		0.036642604,
		0.006914227,
		0.010798231,
		0.033423427,
		-0.04823163,
		0.07843588,
		-0.014808202,
		-0.008691771,
		-0.040057726,
		-0.039161958,
		0.0050701997,
		-0.044900484,
		-0.033479415,
		0.004937234,
		-0.030820096,
		0.056489512,
		-0.030848088,
		0.03891002,
		0.012120891,
		-0.000947382,
		0.0440607,
		0.0071521658,
		0.009020686,
		0.015508023,
		-0.0073131244,
		-0.009699512,
		-0.024395743,
		-0.033507407,
		-0.026845114,
		0.0010234875,
		0.051814713,
		0.0015815943,
		-0.058001123,
		0.028832605,
		-0.0670708,
		-0.0122188665,
		-0.014920173,
		0.017845424,
		-0.0010890957,
		-0.014990156,
		-0.04389274,
		-0.00846083,
		0.026229274,
		-0.030204253,
		-0.017985387,
		-0.0111761335,
		0.021274544,
		-0.046300124,
		-0.014010407,
		0.0056335554,
		0.010000436,
		0.05475396,
		0.028104791,
		-0.027293,
		-0.027237015,
		0.015312073,
		-0.024983592,
		-0.05072299,
		-0.020098845,
		0.027782874,
		0.012393821,
		0.042605072,
		0.023877876,
		-0.009888464,
		-0.023877876,
		-0.007271135,
		-0.003360888,
		-0.033423427,
		-0.028020814,
		-0.008250884,
		-0.038210202,
		-0.009965444,
		0.031883825,
		0.059400767,
		-0.028090796,
		-0.019119097,
		0.035158984,
		0.037370417,
		0.02635524,
		0.004632812,
		-0.036642604,
		0.013814457,
		-0.014948166,
		-0.019972878,
		-0.011498051,
		-0.00018239072,
		0.035886794,
		-0.030288232,
		0.027516942,
		-0.025445474,
		0.10413329,
		-0.029616404,
		-0.013051652,
		-0.0019367533,
		-0.004440361,
		-0.04187726,
		0.00091414055,
		0.037678335,
		-0.01606788,
		-0.024255779,
		-0.028538682,
		-0.013870442,
		-0.017425532,
		0.011120148,
		-0.036866546,
		0.01867121,
		0.0030389705,
		0.0046678027,
		0.038042244,
		0.025221532,
		0.008943706,
		-0.030904073,
		0.012519789,
		0.02888859,
		0.02273017,
		0.012841706,
		-0.018279312,
		0.010560292,
		-0.008040938,
		-0.0018807676,
		0.045600306,
		0.014024403,
		0.009860471,
		-0.01119013,
		-0.035578877,
		-0.014108381,
		0.012274852,
		0.02888859,
		-0.04624414,
		-0.003056466,
		-0.0436688,
		-0.020812662,
		-0.05548177,
		0.025809381,
		-0.0035900793,
		-0.013905434,
		-0.010952191,
		0.0424931,
		0.0022831645,
		-0.006504832,
		-0.0076560364,
		-0.0037650345,
		0.0026243269,
		0.03373135,
		0.025011586,
		0.023248037,
		0.013408561,
		0.01037134,
		-0.012869699,
		-0.043388873,
		0.015550012,
		-0.010609279,
		-0.0046852985,
		0.005923981,
		0.012414816,
		-0.008306869,
		-0.01930105,
		0.0023443988,
		0.015270084,
		0.01805537,
		0.009559548,
		-0.026747141,
		-0.015899923,
		0.007663035,
		0.02620128,
		0.02284214,
		-0.0008739009,
		0.002947994,
		0.0056335554,
		-0.038182206,
		0.020210817,
		-0.0063018836,
		0.050023172,
		0.054446038,
		0.010812227,
		-0.0025176043,
		0.007099679,
		-0.05727331,
		0.02600533,
		0.033591386,
		-0.03879805,
		-0.009342604,
		0.03255565,
		-0.015955908,
		-0.020714687,
		0.0026908098,
		0.012393821,
		0.014003408,
		0.010434324,
		-0.04397672,
		0.01329659,
		-0.001723308,
		-0.03700651,
		0.004034465,
		0.014514278,
		0.04713991,
		-0.011882952,
		0.008495821,
		0.052262597,
		0.011309099,
		-0.028720634,
		-0.008663778,
		-0.034655113,
		-0.01687967,
		0.016235836,
		-0.0085798,
		-0.029840346,
		0.020868648,
		-0.042129196,
		0.018251318,
		0.0017696711,
		-0.01836329,
		-0.0017950396,
		0.009860471,
		-0.027530938,
		-0.041149445,
		-0.0016008394,
		-0.009230632,
		-0.028412713,
		0.004013471,
		0.0171596,
		-0.0061304276,
		0.011218123,
		-0.007984952,
		-0.019720942,
		0.008390848,
		0.0049617277,
		0.016599743,
		-0.0021659445,
		-0.033367444,
		0.0013436554,
		0.011148141,
		-0.032807585,
		0.01785942,
		0.0054865927,
		0.013667495,
		0.033367444,
		0.011022173,
		-0.028244756,
		-0.0076560364,
		-0.03420723,
		0.054949906,
		0.001840528,
		-0.009174647,
		-0.017523507,
		0.011141143,
		-0.02733499,
		0.029392462,
		-0.013765469,
		0.00017659533,
		0.027320992,
		0.008551807,
		0.039161958,
		0.011099153,
		0.0002982985,
		0.006616803,
		0.029924326,
		0.026747141,
		-0.0005882866,
		0.0025718403,
		0.024591694,
		-0.021638451,
		-0.028398717,
		-0.0044753524,
		-0.024703665,
		0.0046188156,
		0.026663162,
		-0.0071801585,
		-0.029560419,
		-0.011980928,
		-0.000810917,
		-0.03420723,
		-0.015689977,
		0.01263176,
		-0.009832478,
		-0.0074110995,
		0.034179233,
		0.020966623,
		0.02113458,
		-0.005626557,
		0.013065649,
		-0.022856139,
		-0.05128285,
		0.010357344,
		0.006116431,
		-0.00004130581,
		0.03233171,
		-0.012120891,
		-0.010560292,
		0.013121635,
		-0.0026890603,
		0.036390666,
		-0.00846083,
		0.010560292,
		0.012526787,
		-0.020126838,
		-0.01890915,
		0.006137426,
		0.0054795947,
		0.02779687,
		-0.0032891564,
		0.01317762,
		0.0043248907,
		-0.00888772,
		-0.051814713,
		-0.009517559,
		0.004471853,
		-0.005759523,
		0.025711406,
		-0.00073437416,
		-0.043108944,
		-0.00409395,
		-0.020168828,
		0.051534783,
		0.007775006,
		0.009482568,
		-0.018391283,
		-0.010182388,
		-0.00012170316,
		-0.009265624,
		-0.0065748137,
		0.0067987563,
		-0.027069058,
		-0.016991641,
		-0.029392462,
		0.0032699113,
		0.026117302,
		0.009104665,
		-0.015088131,
		-0.011141143,
		-0.019483004,
		0.009048679,
		0.0014328825,
		-0.0022446744,
		0.029364469,
		0.005280146,
		0.03541092,
		0.0029882337,
		0.029392462,
		-0.0050736987,
		0.005014214,
		-0.031575903,
		-0.06085639,
		-0.013079645,
		-0.019063111,
		-0.03412325,
		-0.015508023,
		0.018531248,
		0.035382926,
		-0.018083362,
		0.0070716864,
		0.0037685335,
		-0.011239118,
		-0.033143498,
		-0.011994923,
		-0.018769186,
		0.012778723,
		0.001099593,
		-0.02288413,
		-0.01193194,
		-0.0018300307,
		0.01181297,
		0.019343039,
		0.03594278,
		-0.0035778324,
		-0.00962953,
		0.014626249,
		0.00970651,
		0.026299255,
		-0.060520478,
		-0.012316841,
		-0.002640073,
		0.017299563,
		-0.0021519482,
		0.010973185,
		0.023877876,
		-0.048427578,
		-0.012099897,
		-0.0085168155,
		0.022338271,
		-0.026425222,
		-0.08011545,
		0.036138732,
		0.021344526,
		0.012841706,
		-0.0017241827,
		-0.009027685,
		-0.0043213917,
		0.0006412105,
		0.012484798,
		-0.048287615,
		0.033703357,
		-0.0045803254,
		0.010049422,
		-0.028244756,
		-0.013044654,
		0.0018177838,
		0.013933427,
		-0.017453523,
		-0.008712766,
		-0.009335605,
		-0.00573153,
		-0.0510869,
		-0.00440537,
		0.019678952,
		-0.021652447,
		-0.029560419,
		-0.0081879,
		0.017523507,
		0.034963034,
		0.004020469,
		-0.018195333,
		0.047111917,
		-0.017929401,
		-0.015130119,
		0.060800407,
		0.015703972,
		-0.028664649,
		0.04078554,
		-0.00717316,
		-0.0065293256,
		-0.036614608,
		-0.031827837,
		0.015424044,
		0.020966623,
		0.014486285,
		-0.033983283,
		-0.023583952,
		-0.0031369454,
		0.017131606,
		0.024857625,
		-0.0038140218,
		0.018293308,
		-0.0038000254,
		-0.025683412,
		-0.014458292,
		-0.02187639,
		0.00035144112,
		-0.01317762,
		-0.0029882337,
		0.023653934,
		-0.0033136501,
		-0.0038315174,
		-0.04408869,
		-0.018097358,
		0.05329833,
		-0.006693783,
		0.04417267,
		0.008299871,
		-0.0115260435,
		-0.0007146917,
		-0.021568468,
		0.0072921296,
		0.015675979,
		0.03949787,
		0.011700999,
		-0.035662852,
		0.020672698,
		-0.046524066,
		-0.020182824,
		0.0064243525,
		0.0031631887,
		0.0016874422,
		-0.021232555,
		-0.041009482,
		0.009853473,
		0.0031999294,
		0.007061189,
		-0.05430607,
		0.027684899,
		0.023569955,
		0.000055192875,
		0.009048679,
		0.045292385,
		0.008264881,
		-0.003166688,
		0.022408253,
		-0.010119405,
		-0.0110641625,
		0.022940116,
		0.03205178,
		0.0171596,
		0.034739092,
		0.036362674,
		0.008523813,
		0.04296898,
		0.00015286704,
		0.0051016915,
		-0.0030757112,
		-0.026887104,
		-0.0002619953,
		0.028944576,
		0.074180976,
		0.024661675,
		0.01099418,
		0.011617021,
		-0.026229274,
		-0.03790228,
		0.0017617982,
		-0.021708433,
		-0.014129376,
		-0.007194155,
		0.038182206,
		0.0069772108,
		0.0010619776,
		-0.000848095,
		-0.011267111,
		0.0031596897,
		0.008992693,
		-0.0059869643,
		-0.019007126,
		-0.05150679,
		-0.017551498,
		-0.00300223,
		0.02975637,
		0.012652755,
		-0.04198923,
		0.04568428,
		0.008523813,
		-0.009531556,
		-0.0061269286,
		-0.04565629,
		0.0026365737,
		-0.0031439436,
		0.02058872,
		-0.053830195,
		-0.023527965,
		0.0012264354,
		-0.032219738,
		-0.008222891,
		-0.008922712,
		-0.0068827346,
		-0.0031299472,
		0.007572058,
		0.01984691,
		-0.0031964302,
		0.004163932,
		-0.022366263,
		-0.0066657905,
		0.028566673,
		-0.008950705,
		-0.0006648295,
		0.01820933,
		-0.0022796653,
		0.016753703,
		-0.027027069,
		0.014752217,
		0.005930979,
		-0.0064663417,
		-0.0061584204,
		-0.039945755,
		-0.03969382,
		-0.0049512303,
		0.016235836,
		-0.031239988,
		-0.029000562,
		-0.042829014,
		-0.015396051,
		-0.027265007,
		0.0035533386,
		-0.0047167903,
		0.025375493,
		-0.007509074,
		0.020448755,
		-0.0067357724,
		-0.026649166,
		0.0077540115,
		-0.014234349,
		-0.014010407,
		0.016837683,
		-0.004160433,
		-0.00627739,
		-0.008194898,
		-0.020000871,
		-0.0045593306,
		-0.022254292,
		0.024899613,
		0.011547038,
		0.06102435,
		-0.03524296,
		0.013261599,
		0.034991026,
		0.011945936,
		-0.031603895,
		-0.04408869,
		0.006035952,
		0.032779593,
		-0.014514278,
		-0.002862266,
		0.0075580617,
		-0.011365085,
		0.034795076,
		0.0028500191,
		-0.014472288,
		0.020756677,
		-0.007663035,
		0.021470493,
		-0.024843628,
		0.05626557,
		0.030876081,
		-0.01275073,
		-0.022128325,
		0.030036297,
		-0.0024423737,
		0.0017967892,
		0.012260855,
		-0.0064698406,
		0.01345055,
		-0.072669365,
		0.0015903421,
		0.011274109,
		-0.010413329,
		0.03918995,
		-0.0010436074,
		0.006952717,
		0.00008654811,
		-0.0016629485,
		-0.011659009,
		-0.014990156,
		0.020000871,
		-0.0253475,
		0.015438041,
		0.011204126,
		-0.005899487,
		-0.03434719,
		0.011351089,
		-0.0041044476,
		0.0021309534,
		-0.025529452,
		-0.0129186865,
		0.008369854,
		0.0074180975,
		-0.0040904507,
		-0.008670776,
		0.033815328,
		0.008565803,
		0.019133093,
		-0.0011809472,
		-0.016865674,
		-0.0033818826,
		0.043304894,
		0.026411226,
		-0.0006503957,
		-0.007998949,
		-0.02117657,
		-0.0102523705,
		-0.00036040758,
		0.020658702,
		0.026859112,
		-0.022436246,
		-0.025235528,
		0.046384104,
		-0.038070235,
		0.001629707,
		0.0058749933,
		0.0043878746,
		-0.0077820043,
		-0.019483004,
		0.041261416,
		-0.011127146,
		-0.029392462,
		0.027432965,
		0.004121943,
		0.01528408,
		0.027810868,
		-0.031463932,
		0.002920001,
		-0.0026838116,
		-0.02869264,
		-0.0041464367,
		0.032611635,
		-0.021624453,
		-0.01711761,
		0.02554345,
		0.052234605,
		0.006676288,
		0.0019664958,
		0.022156317,
		0.0032296716,
		-0.015927915,
		0.004877749,
		0.0045908224,
		-0.056601483,
		0.014626249,
		0.020126838,
		0.02386388,
		-0.022296282,
		-0.0010121154,
		-0.015997898,
		-0.0046468084,
		-0.00850282,
		0.03759436,
		0.010770238,
		-0.008600794,
		-0.010035426,
		0.002897257,
		-0.03364737,
		-0.0146542415,
		-0.0031754356,
		0.02788085,
		0.029896332,
		0.029840346,
		0.023877876,
		0.022156317,
		0.011875954,
		-0.02452171,
		-0.0096715195,
		0.0106022805,
		0.02818877,
		0.0010016181,
		0.043388873,
		-0.016487772,
		0.026635168,
		0.004709792,
		0.047503818,
		0.022814149,
		-0.0034641116,
		-0.006438349,
		0.013191617,
		0.037258446,
		-0.0058819912,
		-0.02947644,
		-0.040757548,
		-0.018769186,
		0.02908454,
		0.058001123,
		0.025977338,
		0.025389489,
		-0.015144116,
		-0.017229581,
		0.005563573,
		0.018419277,
		-0.011351089,
		-0.007970956,
		0.02725101,
		-0.004828762,
		-0.004461356,
		-0.0066063055,
		-0.031267982,
		-0.012701742,
		-0.00308096,
		-0.0032349203,
		0.034375183,
		0.008705767,
		-0.013982414,
		0.010014432,
		-0.0017093116,
		0.01626383,
		0.008698769,
		-0.005087695,
		0.021764418,
		0.012890694,
		0.10049423,
		0.0058714943,
		-0.051982667,
		-0.028090796,
		0.02967239,
		0.009867469,
		-0.01119013,
		0.0055705714,
		-0.006851243,
		0.010777236,
		-0.010161394,
		0.008649781,
		0.017677465,
		0.007432094,
		0.031016046,
		0.021694437,
		-0.006676288,
		-0.034683105,
		0.0006197785,
		-0.021526478,
		-0.016655728,
		0.00791497,
		0.034879055,
		0.024269776,
		-0.034459163,
		-0.0006648295,
		-0.023108073,
		0.011050166,
		0.060128577,
		0.01953899,
		0.008901717,
		0.021694437,
		0.01727157,
		0.02877662,
		-0.01617985,
		-0.011050166,
		0.019944884,
		-0.0049932194,
		-0.000004852271,
		-0.03723045,
		-0.018153343,
		0.024423735,
		0.023094077,
		0.010245373,
		0.005623058,
		-0.024941603,
		0.001056729,
		-0.0008861477,
		0.031547908,
		-0.026775133,
		-0.003758036,
		0.0030792102,
		0.017285567,
		-0.010105409,
		0.010812227,
		-0.009139656,
		0.007236144,
		-0.02869264,
		0.053914174,
		-0.011840963,
		0.00080916745,
		-0.010840219,
		0.03879805,
		0.016347807,
		0.005115688,
		0.03594278,
		0.006203909,
		0.015955908,
		-0.016865674,
		0.02986834,
		-0.017565494,
		-0.0022604202,
		0.002834273,
		0.016151857,
		0.0013830203,
		-0.007229146,
		-0.024297768,
		-0.020644706,
		-0.022086335,
		0.01356952,
		0.012316841,
		-0.010805229,
		0.022156317,
		0.0012745481,
		0.009692514,
		-0.008915713,
		-0.018783182,
		-0.038182206,
		0.06320779,
		0.02480164,
		0.0035655855,
		0.003443117,
		0.019706946,
		0.0070786844,
		0.002491361,
		0.0022639195,
		-0.009468571,
		0.044872493,
		-0.009125659,
		-0.013877441,
		0.013506536,
		0.009972442,
		-0.023513969,
		0.011085157,
		0.030176261,
		0.026523197,
		-0.04775575,
		-0.017243577,
		-0.02655119,
		0.016305817,
		0.023234041,
		-0.012274852,
		0.028664649,
		-0.006074442,
		0.020378774,
		-0.0008704018,
		-0.017747449,
		0.005049205,
		-0.021974364,
		-0.023485977,
		-0.004573327,
		-0.015186105,
		0.023248037,
		-0.022520224,
		0.021148575,
		-0.0075020758,
		0.012729735,
		0.03700651,
		-0.0035708342,
		-0.024073826,
		0.013814457,
		0.005902986,
		-0.004846257,
		0.039609842,
		0.012022916,
		-0.021386515,
		-0.0019717442,
		-0.022716174,
		0.0072221477,
		-0.0060184565,
		-0.007998949,
		-0.008376852,
		-0.015522019,
		-0.033703357,
		0.008593796,
		0.034403175,
		-0.02615929,
		-0.015717968,
		-0.021512482,
		-0.014724224,
		-0.0167677,
		0.024969596,
		0.0068792356,
		-0.02635524,
		-0.0023478977,
		0.022786155,
		-0.03185583,
		-0.019818917,
		-0.002393386,
		0.014500281,
		0.0067287744,
		-0.0018300307,
		-0.015396051,
		-0.016151857,
		0.009258625,
		-0.005937977,
		-0.02030879,
		-0.02888859,
		-0.022982106,
		-0.0059939628,
		0.015717968,
		-0.023597948,
		-0.014514278,
		0.019804921,
		0.002627826,
		0.017607484,
		0.0070506916,
		0.03591479,
		-0.032583643,
		-0.0031159509,
		-0.004832261,
		-0.05021912,
		-0.008271879,
		-0.037454393,
		0.008005947,
		0.022282286,
		-0.04624414,
		-0.04425665,
		-0.008222891,
		-0.009216636,
		0.018279312,
		0.008047936,
		-0.0071346704,
		0.013772468,
		-0.001684818,
		0.03535493,
		-0.009468571,
		-0.031044038,
		-0.01836329,
		0.020840654,
		-0.0003083584,
		-0.009335605,
		0.044396613,
		-0.05089095,
		0.004573327,
		0.0052451547,
		0.009580543,
		-0.019385029,
		-0.006504832,
		-0.012967674,
		0.030792102,
		-0.0030774607,
		0.025571441,
		-0.008124916,
		0.032667622,
		-0.0049337344,
		0.004468354,
		0.026859112,
		-0.01700564,
		0.0061969105,
		-0.017453523,
		0.013534529,
		-0.025767392,
		-0.025445474,
		-0.00440537,
		0.01696365,
		-0.007362112,
		-0.033255473,
		-0.011847962,
		-0.0005882866,
		0.023304023,
		0.000010695499,
		-0.017747449,
		0.025053574,
		0.033087514,
		0.01173599,
		-0.025431478,
		-0.016445782,
		-0.0036250702,
		-0.046776004,
		0.0038700073,
		0.025319505,
		-0.022324275,
		0.009153652,
		0.00071075524,
		0.023681926,
		-0.017215585,
		-0.009251627,
		-0.001056729,
		0.019916892,
		0.047867723,
		0.021232555,
		0.038462136,
		-0.021848397,
		-0.030204253,
		0.003532344,
		0.012197872,
		0.014017405,
		-0.023751909,
		-0.040141705,
		-0.015689977,
		-0.025473466,
		0.012813713,
		-0.051422812,
		-0.016165854,
		-0.04067357,
		0.010959189,
		-0.025165547,
		-0.0214425,
		0.039441884,
		-0.00024121939,
		-0.022982106,
		-0.013604511,
		0.006543322,
		-0.04109346,
		-0.02030879,
		0.018923147,
		-0.013562522,
		0.008040938,
		-0.002039977,
		-0.0053011402,
		0.0023251537,
		0.0006070943,
		-0.018657215,
		0.050555035,
		-0.012785721,
		-0.03599877,
		-0.015508023,
		-0.007068187,
		-0.008208895,
		-0.034375183,
		0.0050352085,
		-0.008467828,
		-0.0067707635,
		0.004779774,
		0.05150679,
		-0.011631017,
		-0.000904518,
		-0.0068827346,
		-0.0016428287,
		-0.027600922,
		-0.03387131,
		-0.002802781,
		0.0016996891,
		-0.037454393,
		0.024465725,
		0.015214098,
		0.00079648325,
		0.014724224,
		0.021302536,
		-0.028860599,
		-0.010147397,
		-0.016515763,
		0.03048418,
		0.009104665,
		0.0058539985,
		0.046971954,
		-0.02366793,
		-0.027516942,
		0.0075930525,
		0.0011835714,
		0.015759958,
		-0.0067952573,
		-0.022562213,
		0.035298947,
		-0.02986834,
		-0.023108073,
		-0.0155780045,
		0.020812662,
		0.018223327,
		0.013163624,
		0.014248346,
		0.008621789,
		-0.018839167,
		0.036250703,
		-0.008663778,
		-0.016809689,
		0.005514586,
		0.007236144,
		-0.01953899,
		-0.015773954,
		0.006525826,
		0.0072921296,
		0.03333945,
		0.02308008,
		0.05119887,
		0.020630708,
		0.03255565,
		0.012365828,
		-0.0028640155,
		-0.020574722,
		0.012848705,
		0.00088133645,
		0.009636529,
		-0.00048681264,
		-0.0075860545,
		0.022940116,
		-0.018937143,
		0.013289591,
		0.031463932,
		-0.0010331101,
		-0.018979132,
		0.002585837,
		-0.014472288,
		-0.02795083,
		0.0054865927,
		0.021526478,
		-0.016207844,
		0.036250703,
		0.004604819,
		-0.044620555,
		0.011938938,
		0.010553294,
		0.030932067,
		-0.017649474,
		-0.017523507,
		-0.044844497,
		-0.011610023,
		-0.009363598,
		-0.04137339,
		0.022520224,
		0.002507107,
		0.013611509,
		-0.008439835,
		0.056685463,
		-0.013436554,
		-0.019860907,
		-0.009503563,
		-0.010623275,
	})
	p := pca.NewPCA(3)
	reducedDim := p.FitTransform(embeddings)

	rows, _ := reducedDim.Dims()

	for i := 0; i < rows; i++ {
		vector := reducedDim.RowView(i)
		fmt.Println(mat.Formatted(vector.T()))
	}
}
@dreaminglwj
Copy link

dreaminglwj commented Apr 26, 2024 via email

@riverlaker
Copy link

riverlaker commented Apr 26, 2024 via email

@danthegoodman1
Copy link
Author

It seems to be an issue with using a single vector. When modifying https://github.com/sjwhitworth/golearn/blob/master/pca/pca_test.go#L10 to use only one row, i also get 0 returned

@danthegoodman1
Copy link
Author

With sklearn I get a similar issue:

ValueError: Expected 2D array, got 1D array instead:
array=[ 0.00516817  0.01718759 -0.01868521 ... -0.01986091 -0.00950356
 -0.01062327].
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.

@danthegoodman1
Copy link
Author

Probably should throw a similar error if it's not possible, rather than just returning 0's

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