Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tree regularized logistic regression and fixed least squares re…
…gressors support
- Loading branch information
Showing
10 changed files
with
580 additions
and
62 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
examples/undocumented/libshogun/transfer_multitasklogisticregression.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <shogun/labels/RegressionLabels.h> | ||
#include <shogun/features/DenseFeatures.h> | ||
#include <shogun/transfer/multitask/Task.h> | ||
#include <shogun/transfer/multitask/TaskGroup.h> | ||
#include <shogun/transfer/multitask/MultitaskLogisticRegression.h> | ||
#include <shogun/base/init.h> | ||
#include <shogun/lib/common.h> | ||
#include <shogun/io/SGIO.h> | ||
|
||
using namespace shogun; | ||
|
||
void print_message(FILE* target, const char* str) | ||
{ | ||
fprintf(target, "%s", str); | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
init_shogun(&print_message); | ||
|
||
// create some data | ||
SGMatrix<float64_t> matrix(2,4); | ||
for (int32_t i=0; i<2*4; i++) | ||
matrix.matrix[i]=i; | ||
|
||
CDenseFeatures<float64_t>* features= new CDenseFeatures<float64_t>(matrix); | ||
|
||
// create three labels | ||
CRegressionLabels* labels=new CRegressionLabels(4); | ||
labels->set_label(0, -1); | ||
labels->set_label(1, +1); | ||
labels->set_label(2, -1); | ||
labels->set_label(3, +1); | ||
|
||
CTask* first_task = new CTask(0,2); | ||
CTask* second_task = new CTask(2,4); | ||
|
||
CTaskGroup* task_group = new CTaskGroup(); | ||
task_group->add_task(first_task); | ||
task_group->add_task(second_task); | ||
|
||
CMultitaskLogisticRegression* regressor = new CMultitaskLogisticRegression(0.5,features,labels,task_group); | ||
regressor->train(); | ||
|
||
regressor->set_current_task(0); | ||
regressor->get_w().display_vector(); | ||
SG_UNREF(regressor); | ||
exit_shogun(); | ||
return 0; | ||
} |
Oops, something went wrong.