NovembreLab / feems

MIT License
16 stars 14 forks source link

A error in the process of Cross validaition #11

Open Yung-Chien opened 2 years ago

Yung-Chien commented 2 years ago

Hi @haywse @jhmarcus ,

I 'm trying to run the Cross validaition pipeline like tutorial mentioned, and I got this error in the cv_err command:

>>>cv_err = run_cv(sp_graph, lamb_grid, n_folds=sp_graph.n_observed_nodes, factr=1e10) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/feems/cross_validation.py", line 26, in run_cv sp_graph.fit_null_model(verbose=inner_verbose) File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/feems/spatial_graph.py", line 312, in fit_null_model res = minimize(neg_log_lik_w0_s2, [0.0, 0.0], method="Nelder-Mead", args=(obj)) File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/scipy/optimize/_minimize.py", line 606, in minimize return _minimize_neldermead(fun, x0, args, callback, **options) File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/scipy/optimize/optimize.py", line 689, in _minimize_neldermead fsim[k] = func(sim[k]) File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/scipy/optimize/optimize.py", line 427, in function_wrapper return function(*(wrapper_args + args)) File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/feems/objective.py", line 200, in neg_log_lik_w0_s2 obj.sp_graph.comp_graph_laplacian(obj.sp_graph.w) File "/home/xxx/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/feems/spatial_graph.py", line 241, in comp_graph_laplacian self.factor = cholmod.cholesky(self.L_block["dd"]) File "sksparse/cholmod.pyx", line 1188, in sksparse.cholmod.cholesky File "sksparse/cholmod.pyx", line 1216, in sksparse.cholmod._cholesky File "sksparse/cholmod.pyx", line 603, in sksparse.cholmod.Factor._cholesky_inplace File "sksparse/cholmod.pyx", line 598, in sksparse.cholmod.Factor._cholesky_inplace File "sksparse/cholmod.pyx", line 386, in sksparse.cholmod._error_handler sksparse.cholmod.CholmodNotPositiveDefiniteError: ../Supernodal/t_cholmod_super_numeric.c:911: matrix not positive definite (code 1) So why do I have this question and how could fix this?

Thanks in advances, Yung-Chien

VivaswatS commented 11 months ago

Hi @Yung-Chien, we sometimes run into numerical issues like this depending on the data set. I would try figuring out which lambda value causes this and remove it from the grid search. If there are multiple lambda values that give you this same error, it might be symptomatic of some underlying issue with the data