-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add NonParametricMachine class #5055
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ SHARED_RANDOM_INTERFACE(shogun::Machine) | |
%shared_ptr(shogun::LinearMachine) | ||
%shared_ptr(shogun::DistanceMachine) | ||
%shared_ptr(shogun::IterativeMachine<LinearMachine>) | ||
|
||
%shared_ptr(shogun::NonParametricMachine) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to include %include <shogun/machine/NonParametricMachine.h> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After this |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,11 @@ bool Machine::train(std::shared_ptr<Features> data) | |
return result; | ||
} | ||
|
||
bool Machine::train(const std::shared_ptr<Features>& data, const std::shared_ptr<Labels>& lab){ | ||
set_labels(lab); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think like this is fine for now! |
||
return train(data); | ||
} | ||
|
||
void Machine::set_labels(std::shared_ptr<Labels> lab) | ||
{ | ||
if (lab != NULL) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This software is distributed under BSD 3-clause license (see LICENSE file). | ||
* | ||
* Authors: Yuhui Liu | ||
*/ | ||
|
||
#ifndef NONPARAMETRCMACHINE_H_ | ||
#define NONPARAMETRCMACHINE_H_ | ||
|
||
#include <shogun/machine/Machine.h> | ||
LiuYuHui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace shogun | ||
{ | ||
|
||
class NonParametricMachine : public Machine | ||
{ | ||
public: | ||
NonParametricMachine(): Machine() | ||
{ | ||
//TODO : when all refactor is done, m_labels should be removed from | ||
//Machine Class | ||
// SG_ADD( | ||
// &m_labels, "labels", "labels used in train machine algorithm", | ||
// ParameterProperties::READONLY); | ||
SG_ADD(&m_features, "features_train", | ||
"Training features of nonparametric model", | ||
ParameterProperties::READONLY); | ||
} | ||
virtual ~NonParametricMachine() | ||
{ | ||
} | ||
|
||
const char* get_name() const override{ return "NonParametricMachine"; } | ||
|
||
protected: | ||
|
||
std::shared_ptr<Features> m_features; | ||
|
||
//TODO | ||
// when all refactor is done, we should use this m_labels | ||
// std::shared_ptr<Labels> m_labels; | ||
LiuYuHui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} // namespace shogun | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this API is much better