| 7 | #include "api.h" |
| 8 | |
| 9 | std::tuple<Eigen::MatrixXd, Eigen::VectorXd, double, double, double> pywrap_GLM( |
| 10 | Eigen::MatrixXd x_Mat, Eigen::MatrixXd y_Mat, Eigen::VectorXd weight_Vec, int n, int p, int normalize_type, |
| 11 | int algorithm_type, int model_type, int max_iter, int exchange_num, int path_type, bool is_warm_start, |
| 12 | int eval_type, double ic_coef, int Kfold, Eigen::VectorXi gindex_Vec, Eigen::VectorXi sequence_Vec, |
| 13 | Eigen::VectorXd lambda_sequence_Vec, Eigen::VectorXi cv_fold_id_Vec, int s_min, int s_max, double lambda_min, |
| 14 | double lambda_max, int n_lambda, int screening_size, Eigen::VectorXi always_select_Vec, |
| 15 | int primary_model_fit_max_iter, double primary_model_fit_epsilon, bool early_stop, bool approximate_Newton, |
| 16 | int thread, bool covariance_update, bool sparse_matrix, int splicing_type, int sub_search, |
| 17 | Eigen::VectorXi A_init_Vec, bool fit_intercept, double beta_low, double beta_high) { |
| 18 | List mylist = abessGLM_API(x_Mat, y_Mat, n, p, normalize_type, weight_Vec, algorithm_type, model_type, max_iter, |
| 19 | exchange_num, path_type, is_warm_start, eval_type, ic_coef, Kfold, sequence_Vec, |
| 20 | lambda_sequence_Vec, s_min, s_max, lambda_min, lambda_max, n_lambda, screening_size, |
| 21 | gindex_Vec, always_select_Vec, primary_model_fit_max_iter, primary_model_fit_epsilon, |
| 22 | early_stop, approximate_Newton, thread, covariance_update, sparse_matrix, splicing_type, |
| 23 | sub_search, cv_fold_id_Vec, A_init_Vec, fit_intercept, beta_low, beta_high); |
| 24 | |
| 25 | std::tuple<Eigen::MatrixXd, Eigen::VectorXd, double, double, double> output; |
| 26 | int y_col = y_Mat.cols(); |
| 27 | if (y_col == 1 && model_type != 5 && model_type != 6) { |
| 28 | Eigen::VectorXd beta; |
| 29 | double coef0 = 0; |
| 30 | double train_loss = 0; |
| 31 | double test_loss = 0; |
| 32 | double ic = 0; |
| 33 | mylist.get_value_by_name("beta", beta); |
| 34 | mylist.get_value_by_name("coef0", coef0); |
| 35 | mylist.get_value_by_name("train_loss", train_loss); |
| 36 | mylist.get_value_by_name("test_loss", test_loss); |
| 37 | mylist.get_value_by_name("ic", ic); |
| 38 | |
| 39 | Eigen::MatrixXd beta_out(beta.size(), 1); |
| 40 | beta_out.col(0) = beta; |
| 41 | Eigen::VectorXd coef0_out(1); |
| 42 | coef0_out(0) = coef0; |
| 43 | output = std::make_tuple(beta_out, coef0_out, train_loss, test_loss, ic); |
| 44 | } else { |
| 45 | Eigen::MatrixXd beta; |
| 46 | Eigen::VectorXd coef0; |
| 47 | double train_loss = 0; |
| 48 | double test_loss = 0; |
| 49 | double ic = 0; |
| 50 | mylist.get_value_by_name("beta", beta); |
| 51 | mylist.get_value_by_name("coef0", coef0); |
| 52 | mylist.get_value_by_name("train_loss", train_loss); |
| 53 | mylist.get_value_by_name("test_loss", test_loss); |
| 54 | mylist.get_value_by_name("ic", ic); |
| 55 | |
| 56 | output = std::make_tuple(beta, coef0, train_loss, test_loss, ic); |
| 57 | } |
| 58 | return output; |
| 59 | } |
| 60 | |
| 61 | std::tuple<Eigen::MatrixXd, double, double, double, double> pywrap_PCA( |
| 62 | Eigen::MatrixXd x_Mat, Eigen::VectorXd weight_Vec, int n, int p, int normalize_type, Eigen::MatrixXd sigma_Mat, |
no test coverage detected