19 using namespace Eigen;
37 void CLinearRidgeRegression::init()
51 REQUIRE(data,
"No features provided and no featured previously set\n");
54 "Number of training vectors (%d) does not match number of labels (%d)\n",
58 "Expected Dense Features (%d) but got (%d)\n",
62 "Expected Real Features (%d) but got (%d)\n",
66 int32_t num_feat=feats->get_num_features();
78 Map<MatrixXd> eigen_feats_matrix(feats_matrix.matrix, num_feat,num_vec);
83 eigen_kernel_matrix = eigen_feats_matrix*eigen_feats_matrix.transpose();
85 eigen_kernel_matrix.diagonal() += eigen_tau;
87 eigen_y = eigen_feats_matrix*eigen_labels ;
90 llt.compute(eigen_kernel_matrix);
91 if(llt.info() != Eigen::Success)
93 SG_WARNING(
"Features covariance matrix was not positive definite\n");
96 eigen_y = llt.solve(eigen_y);
Real Labels are real-valued labels.
virtual void set_w(const SGVector< float64_t > src_w)
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
virtual int32_t get_num_vectors() const =0
virtual bool save(FILE *dstfile)
virtual CLabels * get_labels()
virtual void set_features(CDotFeatures *feat)
virtual EFeatureClass get_feature_class() const =0
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
virtual bool load(FILE *srcfile)
virtual bool train_machine(CFeatures *data=NULL)
virtual void set_labels(CLabels *lab)
virtual EFeatureType get_feature_type() const =0
void add(const SGVector< T > x)