50 EMsgType minType = kINFO ) :
80 <<
"---------------------------------------------------------------------------\n"
81 <<
"- You are running the interface to Jerome Friedmans RuleFit(tm) code. -\n"
82 <<
"- For a full manual see the following web page: -\n"
84 <<
"- http://www-stat.stanford.edu/~jhf/R-RuleFit.html -\n"
86 <<
"---------------------------------------------------------------------------"
96 <<
"------------------------ RULEFIT-JF INTERFACE SETUP -----------------------\n"
98 <<
"1. Create a rulefit directory in your current work directory:\n"
100 <<
" the directory may be set using the option RuleFitDir\n"
102 <<
"2. Copy (or make a link) the file rf_go.exe into this directory\n"
104 <<
"The file can be obtained from Jerome Friedmans homepage (linux):\n"
105 <<
" wget http://www-stat.stanford.edu/~jhf/r-rulefit/linux/rf_go.exe\n"
107 <<
"Don't forget to do:\n"
108 <<
" chmod +x rf_go.exe\n"
110 <<
"For Windows download:\n"
111 <<
" http://www-stat.stanford.edu/~jhf/r-rulefit/windows/rf_go.exe\n"
113 <<
"NOTE: other platforms are not supported (see Friedmans homepage)\n"
115 <<
"---------------------------------------------------------------------------\n"
144 if (
fRuleFit->GetRuleEnsemblePtr()->DoOnlyLinear() )
146 else if (
fRuleFit->GetRuleEnsemblePtr()->DoOnlyRules() )
172 fLogger << kFATAL <<
"Setup failed - aborting!" <<
Endl;
175 FILE *
f = fopen(
"rf_go.exe",
"r");
179 fLogger << kFATAL <<
"Setup failed - aborting!" <<
Endl;
315 program =
"rulefit_pred";
349 fLogger << kWARNING <<
"WriteRfOut is not yet implemented" <<
Endl;
358 fLogger << kWARNING <<
"WriteRfStatus is not yet implemented" <<
Endl;
367 fLogger << kWARNING <<
"WriteRuleFitMod is not yet implemented" <<
Endl;
376 fLogger << kWARNING <<
"WriteRuleFitSum is not yet implemented" <<
Endl;
455 f <<
fMethodRuleFit->DataInfo().GetVariableInfo(ivar).GetExpression() <<
'\n';
466 fLogger << kWARNING <<
"WriteVarImp is not yet implemented" <<
Endl;
475 fLogger << kWARNING <<
"WriteYhat is not yet implemented" <<
Endl;
491 neve =
static_cast<Int_t>(xval);
493 fLogger << kWARNING <<
"Inconsistent size of yhat file and test tree!" <<
Endl;
520 for (
UInt_t ivar=0; ivar<nvars; ivar++) {
533 for (
UInt_t ivar=0; ivar<nvars; ivar++) {
548 fLogger << kVERBOSE <<
"Reading RuleFit summary file" <<
Endl;
560 fRuleFit->GetRuleEnsemblePtr()->SetAverageRuleSigma(0.4);
589 norules = (nrules==1);
591 norules = norules && (dumI==1);
593 norules = norules && (dumI==1);
595 norules = norules && (dumI==0);
596 if (nrules==0) norules=
kTRUE;
597 if (norules) nrules = 0;
603 fLogger << kDEBUG <<
"N(rules) = " << nrules <<
Endl;
604 fLogger << kDEBUG <<
"N(vars) = " << nvars <<
Endl;
605 fLogger << kDEBUG <<
"N(varsO) = " << nvarsOpt <<
Endl;
608 if (nvars!=nvarsOpt) {
609 fLogger << kWARNING <<
"Format of rulefit.sum is ... weird?? Continuing but who knows how it will end...?" <<
Endl;
611 std::vector<Double_t> rfSupp;
612 std::vector<Double_t> rfCoef;
613 std::vector<Int_t> rfNcut;
614 std::vector<Rule *> rfRules;
618 for (
Int_t t=0; t<8; t++) {
636 rfSupp.push_back(dumF);
638 rfCoef.push_back(dumF);
640 rfNcut.push_back(
static_cast<int>(dumF+0.5));
659 rfRules.push_back( rule );
677 if (imp>impref) impref = imp;
679 fLogger << kDEBUG <<
"Rule #" <<
r <<
" : " << nvars <<
Endl;
680 fLogger << kDEBUG <<
" support = " << rfSupp[
r] <<
Endl;
687 varind =
static_cast<Int_t>(dumF+0.5)-1;
703 fRuleFit->GetRuleEnsemblePtr()->SetRules( rfRules );
717 std::vector<Int_t> varind;
718 std::vector<Double_t>
xmin;
719 std::vector<Double_t>
xmax;
720 std::vector<Double_t> average;
721 std::vector<Double_t> stdev;
722 std::vector<Double_t> norm;
723 std::vector<Double_t> coeff;
727 varind.push_back(
static_cast<Int_t>(dumF+0.5)-1);
733 average.push_back(
static_cast<Double_t>(dumF));
735 stdev.push_back(
static_cast<Double_t>(dumF));
739 coeff.push_back(dumF/nv);
742 fLogger << kDEBUG <<
" varind = " << varind.back() <<
Endl;
745 fLogger << kDEBUG <<
" average = " << average.back() <<
Endl;
746 fLogger << kDEBUG <<
" stdev = " << stdev.back() <<
Endl;
747 fLogger << kDEBUG <<
" coeff = " << coeff.back() <<
Endl;
750 fRuleFit->GetRuleEnsemblePtr()->SetLinCoefficients(coeff);
753 fRuleFit->GetRuleEnsemblePtr()->SetLinNorm(norm);
756 imp =
fRuleFit->GetRuleEnsemblePtr()->CalcLinImportance();
757 if (imp>impref) impref=imp;
758 fRuleFit->GetRuleEnsemblePtr()->SetImportanceRef(impref);
759 fRuleFit->GetRuleEnsemblePtr()->CleanupLinear();
761 fRuleFit->GetRuleEnsemblePtr()->CalcVarImportance();
776 int rval =
gSystem->Exec(cmd.Data());
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TSystem * gSystem
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not.
J Friedman's RuleFit method.
const TString GetRFWorkDir() const
A class describing a 'rule cut'.
void SetSelector(Int_t i, UInt_t s)
void SetCutDoMin(Int_t i, Bool_t v)
void SetCutMin(Int_t i, Double_t v)
void SetCutMax(Int_t i, Double_t v)
void SetCutDoMax(Int_t i, Bool_t v)
J Friedman's RuleFit method.
void SetTestParms()
set the test params
Bool_t WriteRuleFitSum()
written by rf_go.exe (NOTE: format unknown!)
Bool_t WriteYhat()
written by rf_go.exe
Int_t ReadFloat(std::ifstream &f, Float_t *v, Int_t n=1) const
Bool_t WriteAll()
write all files read by rf_go.exe
void ImportSetup()
import setup from MethodRuleFit
Bool_t WriteRfStatus()
written by rf_go.exe; write rulefit status
Bool_t WriteIntParms()
write int params file
void CheckRFWorkDir()
check if the rulefit work dir is properly setup.
Bool_t WriteProgram()
write command to rf_go.exe
Bool_t ReadModelSum()
read model from rulefit.sum
void SetRFWorkDir(const char *wdir)
set the directory containing rf_go.exe.
Bool_t ReadVarImp()
read variable importance
Bool_t WriteRuleFitMod()
written by rf_go.exe (NOTE:Format unknown!)
Bool_t WriteRfOut()
written by rf_go.exe; write rulefit output (rfout)
RealParms fRFRealParms
real parameters
RuleFit * fRuleFit
non const ptr to RuleFit class in MethodRuleFit
Bool_t OpenRFile(TString name, std::ofstream &f)
void InitRuleFit()
default initialisation SetRFWorkDir("./rulefit");
void FillRealParmsDef()
set default real params
std::vector< Float_t > fRFVarImp
variable importances
Bool_t WriteVarNames()
write variable names, ascii
ERFProgram fRFProgram
what to run
Bool_t WriteRealVarImp()
write the minimum importance to be considered
void FillIntParmsDef()
set default int params
void WelcomeMessage()
welcome message
Bool_t WriteTrain()
write training data, column wise
virtual ~RuleFitAPI()
destructor
Bool_t WriteRealParms()
write int params file
Bool_t WriteFloat(std::ofstream &f, const Float_t *v, Int_t n=1)
MsgLogger fLogger
! message logger
const MethodRuleFit * fMethodRuleFit
parent method - set in constructor
Int_t ReadInt(std::ifstream &f, Int_t *v, Int_t n=1) const
IntParms fRFIntParms
integer parameters
Bool_t WriteLx()
Save input variable mask.
TString fRFWorkDir
working directory
Bool_t ReadYhat()
read the score
void HowtoSetupRF()
howto message
std::vector< Float_t > fRFYhat
score results from test sample
std::vector< Int_t > fRFVarImpInd
variable index
std::vector< int > fRFLx
variable selector
Bool_t WriteTest()
Write test data.
void SetTrainParms()
set the training parameters
Bool_t WriteInt(std::ofstream &f, const Int_t *v, Int_t n=1)
Int_t RunRuleFit()
execute rf_go.exe
A class implementing various fits of rule ensembles.
Implementation of a rule.
void SetImportanceRef(Double_t v)
void SetCoefficient(Double_t v)
void SetNorm(Double_t norm)
Double_t GetImportance() const
Double_t GetSigma() const
void SetSSBNeve(Double_t v)
void SetRuleCut(RuleCut *rc)
void SetSupport(Double_t v)
const char * Data() const
MsgLogger & Endl(MsgLogger &ml)