mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-29 08:34:48 +08:00
Automatically sort the features
This commit is contained in:
@@ -207,6 +207,9 @@
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>170</number>
|
||||
</attribute>
|
||||
|
||||
@@ -546,6 +546,8 @@ void q3DMASCPlugin::doTrainAction()
|
||||
}
|
||||
trainDlg.setFeatureImportance(i, originalFeatures[i].importance);
|
||||
}
|
||||
|
||||
trainDlg.sortByFeatureImportance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ bool Tools::LoadClassifierCloudLabels(QString filename, QSet<QString>& labels, Q
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CreateFeaturesFromCommand(const QString& command, int lineNumber, const Tools::NamedClouds& clouds, std::vector<Feature::Shared>& rawFeatures, std::vector<double>& scales)
|
||||
static bool CreateFeaturesFromCommand(const QString& command, QString corePointsRole, int lineNumber, const Tools::NamedClouds& clouds, std::vector<Feature::Shared>& rawFeatures, std::vector<double>& scales)
|
||||
{
|
||||
QStringList tokens = command.split('_');
|
||||
if (tokens.empty())
|
||||
@@ -771,7 +771,7 @@ static bool LoadFileCommon( const QString& filename,
|
||||
{
|
||||
QString command = line.mid(8);
|
||||
|
||||
if (!CreateFeaturesFromCommand(command, lineNumber, clouds, rawFeatures, scales))
|
||||
if (!CreateFeaturesFromCommand(command, corePoints ? corePoints->role : QString(), lineNumber, clouds, rawFeatures, scales))
|
||||
{
|
||||
//error message already issued
|
||||
//return false;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
//System
|
||||
#include <assert.h>
|
||||
|
||||
static const int FeatureImportanceColumn = 1;
|
||||
|
||||
Train3DMASCDialog::Train3DMASCDialog(QWidget* parent/*=nullptr*/)
|
||||
: QDialog(parent)
|
||||
, Ui::Train3DMASCDialog()
|
||||
@@ -79,6 +81,11 @@ bool Train3DMASCDialog::isFeatureSelected(size_t index) const
|
||||
return (tableWidget->item(static_cast<int>(index), 0)->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
void Train3DMASCDialog::sortByFeatureImportance()
|
||||
{
|
||||
tableWidget->sortByColumn(FeatureImportanceColumn, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
void Train3DMASCDialog::setFeatureImportance(size_t index, float importance)
|
||||
{
|
||||
if (static_cast<int>(index) >= tableWidget->rowCount())
|
||||
@@ -89,11 +96,11 @@ void Train3DMASCDialog::setFeatureImportance(size_t index, float importance)
|
||||
|
||||
if (!std::isnan(importance))
|
||||
{
|
||||
tableWidget->item(static_cast<int>(index), 1)->setText(QString::number(importance));
|
||||
tableWidget->item(static_cast<int>(index), FeatureImportanceColumn)->setText(QString::number(importance));
|
||||
}
|
||||
else
|
||||
{
|
||||
tableWidget->item(static_cast<int>(index), 1)->setText(QString());
|
||||
tableWidget->item(static_cast<int>(index), FeatureImportanceColumn)->setText(QString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
|
||||
bool isFeatureSelected(size_t index) const;
|
||||
void setFeatureImportance(size_t index, float importance);
|
||||
void sortByFeatureImportance();
|
||||
|
||||
inline bool shouldSaveClassifier() const { return saveRequested; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user