Hi Changhe, Sorry for the late reply. In line 12, try changing ‘second_order’ with ‘second_order_raw’, i.e.corr_g = (np.diag(SigmaHat_raw) - np.diag(second_order_raw.Ds)) / np.diag(SigmaHat_raw) Hope this helps! Charmaine From: chhuang48202Sent: Friday, June 11, 2021 2:15 PMTo: chicanagram/raman-knockoffsCc: SubscribedSubject: [chicanagram/raman-knockoffs] raman-knockoffs-master/generate_knockoffs.ipynb error (#1) Please see error occurred in line [12]: name 'second_order' is not definedI use Python 3.6Please helpChanghe HuangSigmaHat_raw = np.cov(X_raw, rowvar=False)SigmaHat_raw = SigmaHat_raw*(1-epsilon) + epsilon*np.eye(SigmaHat_raw.shape[0])Initialize knockoffs generatorsecond_order_raw = GaussianKnockoffs(SigmaHat_raw, mu=np.mean(X_raw,0), method="sdp")Measure pairwise second-order knockoff correlationscorr_g = (np.diag(SigmaHat_raw) - np.diag(second_order.Ds)) / np.diag(SigmaHat_raw)print('Average absolute pairwise correlation: %.3f.' %(np.mean(np.abs(corr_g))))Generate knockoffsXk_raw = second_order_raw.generate(X_raw)Initializing Gaussian Knockoffs...Method: sdpSolving SDP...Converted covariance matrix to a correlation matrix.Solving optimization problem using CVXOPT solver...Optimization complete.Obtained SigmaInvDs matrix.Obtained LV matrix.NameError Traceback (most recent call last)in 67 # Measure pairwise second-order knockoff correlations----> 8 corr_g = (np.diag(SigmaHat_raw) - np.diag(second_order.Ds)) / np.diag(SigmaHat_raw)9 print('Average absolute pairwise correlation: %.3f.' %(np.mean(np.abs(corr_g))))10NameError: name 'second_order' is not defined—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
Please see error occurred in line [12]: name 'second_order' is not defined I use Python 3.6 Please help
Changhe Huang
SigmaHat_raw = np.cov(X_raw, rowvar=False) SigmaHat_raw = SigmaHat_raw(1-epsilon) + epsilonnp.eye(SigmaHat_raw.shape[0])
Initialize knockoffs generator
second_order_raw = GaussianKnockoffs(SigmaHat_raw, mu=np.mean(X_raw,0), method="sdp")
Measure pairwise second-order knockoff correlations
corr_g = (np.diag(SigmaHat_raw) - np.diag(second_order.Ds)) / np.diag(SigmaHat_raw) print('Average absolute pairwise correlation: %.3f.' %(np.mean(np.abs(corr_g))))
Generate knockoffs
Xk_raw = second_order_raw.generate(X_raw)
Initializing Gaussian Knockoffs... Method: sdp Solving SDP... Converted covariance matrix to a correlation matrix. Solving optimization problem using CVXOPT solver... Optimization complete. Obtained SigmaInvDs matrix. Obtained LV matrix.
NameError Traceback (most recent call last)