Commit 6a18e957 authored by Pierre-Henri Wuillemin's avatar Pierre-Henri Wuillemin

Merge branch 'master' into documentation/swigDoc

parents 1a6577af b70b59d0
......@@ -81,6 +81,7 @@ apps/pyAgrum/notebooks/*.png
apps/pyAgrum/notebooks/WaterSprinkler.*
apps/pyAgrum/notebooks/*.csv
apps/pyAgrum/notebooks/*.html
.ipynb_checkpoints
apps/pyAgrum/samples/actuel.png
apps/pyAgrum/samples/alarm.csv
......
......@@ -7,11 +7,11 @@ Welcome to aGrUM's contribution guide and thank you for helping us making aGrUM
Before submitting your first contribution, please take the time to fill aGrUM's contribution agreement. We will not accept any contribution without it !
You can find the individual agreement [here](https://gitlab.com/agrumery/aGrUM/wikis/contribution/individual) and the entity agreement
[here](https://gitlab.com/agrumery/aGrUM/wikis/contribution/entity). Please send us your agreeemnt at agrum@lip6.fr.
[here](https://gitlab.com/agrumery/aGrUM/wikis/contribution/entity). Please send us your agreement at [info@agrum.org](mailto:info@agrum.org).
### Why a contribution agreement ?
We are planning to change aGrUM's licence, but don't worry aGrUM will always be Open Source. To do so, we need your agreement as one of aGrUM's contributor. There is also some legal consideration about how your contribution can be used and distributed with aGrUM. So please take your time and read the agreement before sending it to us. And if you have any question, feel free to ask us at agrum@lip6.fr.
We are planning to change aGrUM's licence, but don't worry aGrUM will always be Open Source. To do so, we need your agreement as one of aGrUM's contributor. There is also some legal consideration about how your contribution can be used and distributed with aGrUM. So please take your time and read the agreement before sending it to us. And if you have any question, feel free to ask us at [info@agrum.org](mailto:info@agrum.org).
## What to contribute
......@@ -23,7 +23,7 @@ You can contribute to aGrUM in the following domains:
### Contributing to aGrUM's Code
Before contributing to aGrUM's code you should ask us before hand at agrum@lip6.fr. This will prevent you from submiting code that we won't integrate: aGrUM's is still under heavy development and some featured modules like `bayesnet` or `learning` are refactored quite often.
Before contributing to aGrUM's code you should ask us before hand at [info@agrum.org](mailto:info@agrum.org). This will prevent you from submiting code that we won't integrate: aGrUM's is still under heavy development and some featured modules like `bayesnet` or `learning` are refactored quite often.
Outside of aGrUM's core code, you can help us [solve bugs](https://gitlab.com/agrumery/aGrUM/issues), write [new tests](https://gitlab.com/agrumery/aGrUM/tree/master/src/testunits/README.md) or contribute to one of aGrUM's [applications](https://gitlab.com/agrumery/aGrUM/tree/master/apps/README.md) or [wrappers](https://gitlab.com/agrumery/aGrUM/tree/master/wrappers/README.md).
......@@ -39,6 +39,6 @@ Packaging and distributing aGrUM or pyAgrum helps a lot by leting aGrUM users ea
## How to contribute
For your first contribution you should fork aGrUM, make your contribution and send us a merge request. Before contributing, please take the time to warn us at agrum@lip6.fr so we can help you out with your contribution.
For your first contribution you should fork aGrUM, make your contribution and send us a merge request. Before contributing, please take the time to warn us at [info@agrum.org](mailto:info@agrum.org) so we can help you out with your contribution.
......@@ -12,7 +12,7 @@ The purpose of this contributor agreement ("Agreement") is to clarify and docume
"Affiliate" means any other Legal Entity that controls, is controlled by, or under common control with that Legal Entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such Legal Entity, whether by contract or otherwise, (ii) ownership of fifty percent (50%) or more of the outstanding shares or securities that vote to elect the management or other persons who direct such Legal Entity or (iii) beneficial ownership of such entity.
"Contribution" means any original work of authorship (software and/or documentation) including any modifications or additions to an existing work, Submitted by You to Us, in which You own the Copyright. If You do not own the Copyright in the entire work of authorship, please contact Us at agrum@lip6.fr.
"Contribution" means any original work of authorship (software and/or documentation) including any modifications or additions to an existing work, Submitted by You to Us, in which You own the Copyright. If You do not own the Copyright in the entire work of authorship, please contact Us at info@agrum.org.
"Copyright" means all rights protecting works of authorship owned or controlled by You, including copyright, moral and neighboring rights, as appropriate, for the full term of their existence including any extensions by You.
......
......@@ -8,7 +8,7 @@ The purpose of this contributor agreement ("Agreement") is to clarify and docume
1. DEFINITIONS
"You" means the Individual Copyright owner who submits a Contribution to Us. If You are an employee and submit the Contribution as part of your employment, You have had Your employer approve this Agreement or sign the Entity version of this document.
"Contribution" means any original work of authorship (software and/or documentation) including any modifications or additions to an existing work, Submitted by You to Us, in which You own the Copyright. If You do not own the Copyright in the entire work of authorship, please contact Us at agrum@lip6.fr.
"Contribution" means any original work of authorship (software and/or documentation) including any modifications or additions to an existing work, Submitted by You to Us, in which You own the Copyright. If You do not own the Copyright in the entire work of authorship, please contact Us at info@agrum.org.
"Copyright" means all rights protecting works of authorship owned or controlled by You, including copyright, moral and neighboring rights, as appropriate, for the full term of their existence including any extensions by You.
......
......@@ -53,7 +53,7 @@ namespace gum {
}
for ( const auto& child : __model.dag().children( __node ) ) {
__mb.addNode( child );
if ( !__mb.nodes().exists( child ) ) __mb.addNode( child );
__mb.addArc( __node, child );
for ( const auto& opar : __model.dag().parents( child ) ) {
if ( opar != __node ) {
......
......@@ -149,7 +149,7 @@ namespace gum {
/// Clear all the previously defined marginal targets
virtual void eraseAllMarginalTargets() final;
/// Add a set of nodes as a new joint target
/// Add a set of nodes as a new joint target. As a collateral effect, every node is added as a marginal target.
/**
* @throw UndefinedElement if some node(s) do not belong to the Bayes net
*/
......
......@@ -91,10 +91,13 @@ namespace gum {
// Clear all previously defined targets (single targets and sets of targets)
template <typename GUM_SCALAR>
INLINE void JointTargetedInference<GUM_SCALAR>::eraseAllJointTargets() {
_onAllJointTargetsErased();
__joint_targets.clear();
this->__state =
BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure;
if ( __joint_targets.size() > 0 ) {
// we already are in target mode. So no this->_setTargetedMode(); is needed
_onAllJointTargetsErased();
__joint_targets.clear();
this->__state =
BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure;
}
}
......@@ -141,6 +144,7 @@ namespace gum {
if ( iter->isSubsetOf( joint_target ) ) eraseJointTarget( *iter );
}
this->_setTargetedMode(); // does nothing if already in targeted mode
__joint_targets.insert( joint_target );
_onJointTargetAdded( joint_target );
this->__state =
......@@ -169,6 +173,8 @@ namespace gum {
// check that the joint_target set does not contain the new target
if ( __joint_targets.contains( joint_target ) ) {
// note that we have to be in target mode when we are here
// so, no this->_setTargetedMode(); is necessary
_onJointTargetErased( joint_target );
__joint_targets.erase( joint_target );
this->__state =
......
......@@ -50,9 +50,9 @@ namespace gum {
* the current state of the inference. Note that the MarginalTargetedInference
* is designed to be used in incremental inference engines.
*/
template<typename GUM_SCALAR>
template <typename GUM_SCALAR>
class MarginalTargetedInference : public virtual BayesNetInference<GUM_SCALAR> {
public:
public:
// ############################################################################
/// @name Constructors / Destructors
// ############################################################################
......@@ -62,7 +62,7 @@ namespace gum {
/** @warning By default, all the nodes of the Bayes net are targets.
* @warning note that, by aGrUM's rule, the BN is not copied but only
* referenced by the inference algorithm. */
MarginalTargetedInference(const IBayesNet<GUM_SCALAR> *bn);
MarginalTargetedInference( const IBayesNet<GUM_SCALAR>* bn );
/// destructor
virtual ~MarginalTargetedInference();
......@@ -90,7 +90,7 @@ namespace gum {
*
* @throw UndefinedElement if node is not in the set of targets
*/
virtual const Potential<GUM_SCALAR> &posterior(const NodeId node);
virtual const Potential<GUM_SCALAR>& posterior( const NodeId node );
/// Computes and returns the posterior of a node.
/**
......@@ -108,7 +108,7 @@ namespace gum {
*
* @throw UndefinedElement if node is not in the set of targets
*/
virtual const Potential<GUM_SCALAR> &posterior(const std::string &nodeName);
virtual const Potential<GUM_SCALAR>& posterior( const std::string& nodeName );
/// @}
......@@ -128,35 +128,35 @@ namespace gum {
/**
* @throw UndefinedElement if target is not a NodeId in the Bayes net
*/
virtual void addTarget(const NodeId target) final;
virtual void addTarget( const NodeId target ) final;
/// Add a marginal target to the list of targets
/**
* @throw UndefinedElement if target is not a NodeId in the Bayes net
*/
virtual void addTarget(const std::string &nodeName) final;
virtual void addTarget( const std::string& nodeName ) final;
/// removes an existing (marginal) target
/** @warning If the target does not already exist, the method does nothing.
* In particular, it does not raise any exception. */
virtual void eraseTarget(const NodeId target) final;
virtual void eraseTarget( const NodeId target ) final;
/// removes an existing (marginal) target
/** @warning If the target does not already exist, the method does nothing.
* In particular, it does not raise any exception. */
virtual void eraseTarget(const std::string &nodeName) final;
virtual void eraseTarget( const std::string& nodeName ) final;
/// return true if variable is a (marginal) target
virtual bool isTarget(const NodeId variable) const final;
virtual bool isTarget( const NodeId variable ) const final;
/// return true if variable is a (marginal) target
virtual bool isTarget(const std::string &nodeName) const final;
virtual bool isTarget( const std::string& nodeName ) const final;
/// returns the number of marginal targets
virtual const Size nbrTargets() const noexcept final;
/// returns the list of marginal targets
virtual const NodeSet &targets() const noexcept final;
virtual const NodeSet& targets() const noexcept final;
/// @}
......@@ -169,13 +169,13 @@ namespace gum {
* Compute Shanon's entropy of a node given the observation
* @see http://en.wikipedia.org/wiki/Information_entropy
*/
virtual GUM_SCALAR H(const NodeId X) final;
virtual GUM_SCALAR H( const NodeId X ) final;
/** Entropy
* Compute Shanon's entropy of a node given the observation
* @see http://en.wikipedia.org/wiki/Information_entropy
*/
virtual GUM_SCALAR H(const std::string &nodeName) final;
virtual GUM_SCALAR H( const std::string& nodeName ) final;
///@}
......@@ -191,8 +191,8 @@ namespace gum {
* @param evs the vector of nodeId of the observed variables
* @return a Potential
*/
Potential<GUM_SCALAR> evidenceImpact(NodeId target,
const std::vector<NodeId>& evs);
Potential<GUM_SCALAR> evidenceImpact( NodeId target,
const std::vector<NodeId>& evs );
/**
* Create a gum::Potential for P(target|evs) (for all instanciation of target
......@@ -204,17 +204,17 @@ namespace gum {
* @param evs the nodeId of the observed variable
* @return a Potential
*/
Potential<GUM_SCALAR> evidenceImpact(const std::string& target,
const std::vector<std::string>& evs);
Potential<GUM_SCALAR> evidenceImpact( const std::string& target,
const std::vector<std::string>& evs );
protected:
protected:
/// fired after a new marginal target is inserted
/** @param id The target variable's id. */
virtual void _onMarginalTargetAdded(const NodeId id) = 0;
virtual void _onMarginalTargetAdded( const NodeId id ) = 0;
/// fired before a marginal target is removed
/** @param id The target variable's id. */
virtual void _onMarginalTargetErased(const NodeId id) = 0;
virtual void _onMarginalTargetErased( const NodeId id ) = 0;
/// fired after all the nodes of the BN are added as marginal targets
virtual void _onAllMarginalTargetsAdded() = 0;
......@@ -223,16 +223,19 @@ namespace gum {
virtual void _onAllMarginalTargetsErased() = 0;
/// fired after a new Bayes net has been assigned to the engine
virtual void _onBayesNetChanged(const IBayesNet<GUM_SCALAR> *bn);
virtual void _onBayesNetChanged( const IBayesNet<GUM_SCALAR>* bn );
/// asks derived classes for the posterior of a given variable
/** @param id The variable's id. */
virtual const Potential<GUM_SCALAR> &_posterior(const NodeId id) = 0;
virtual const Potential<GUM_SCALAR>& _posterior( const NodeId id ) = 0;
protected:
void _setTargetedMode();
bool _isTargetedMode() const;
private:
private:
/// whether the actual targets are default
bool __defaultTargets;
bool __targeted_mode;
/// the set of marginal targets
NodeSet __targets;
......
......@@ -119,8 +119,8 @@ namespace gum {
auto start = nn.find_first_of('(');
auto end = nn.find_first_of(')');
if (0 < start && start < end && end < nn.size()) {
auto path = nn.substr(0, start - 1);
auto type = nn.substr(start + 1, end);
auto path = nn.substr(0, start);
auto type = nn.substr(start + 1, end-start-1);
auto name = nn.substr(end + 1, std::string::npos);
std::string newNameRadical = __getVariableName( path, type, name);
......
......@@ -4,7 +4,7 @@ Version: @PYAGRUM_VERSION@
Summary: pyAgrum is a Python wrapper for the C++ aGrUM library
Home-page: https://pyagrum.lip6.fr
Author: Pierre-Henri Wuillemin and Christophe Gonzales
Author-email: agrum@lip6.fr
Author-email: info@agrum.org
License: GPL
Keywords: probabilities probabilistic-graphical-models inference diagnosis
Platform: any
......
......@@ -43,7 +43,7 @@ setup(
description='pyAgrum is a Python wrapper for the C++ aGrUM library',
url='https://pyagrum.lip6.fr',
maintainer='Pierre-Henri Wuillemin and Christophe Gonzales',
maintainer_email='agrum@lip6.fr',
maintainer_email='info@agrum.org',
platforms=['any'],
license='GPL',
packages=['pyAgrum', 'pyAgrum/lib', 'pyAgrum/lib/_utils'],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
PassengerId,Survived
892,0
893,1
894,0
895,0
896,1
897,0
898,1
899,0
900,1
901,0
902,0
903,0
904,1
905,0
906,1
907,1
908,0
909,0
910,1
911,1
912,0
913,0
914,1
915,0
916,1
917,0
918,1
919,0
920,0
921,0
922,0
923,0
924,1
925,1
926,0
927,0
928,1
929,1
930,0
931,0
932,0
933,0
934,0
935,1
936,1
937,0
938,0
939,0
940,1
941,1
942,0
943,0
944,1
945,1
946,0
947,0
948,0
949,0
950,0
951,1
952,0
953,0
954,0
955,1
956,0
957,1
958,1
959,0
960,0
961,1
962,1
963,0
964,1
965,0
966,1
967,0
968,0
969,1
970,0
971,1
972,0
973,0
974,0
975,0
976,0
977,0
978,1
979,1
980,1
981,0
982,1
983,0
984,1
985,0
986,0
987,0
988,1
989,0
990,1
991,0
992,1
993,0
994,0
995,0
996,1
997,0
998,0
999,0
1000,0
1001,0
1002,0
1003,1
1004,1
1005,1
1006,1
1007,0
1008,0
1009,1
1010,0
1011,1
1012,1
1013,0
1014,1
1015,0
1016,0
1017,1
1018,0
1019,1
1020,0
1021,0
1022,0
1023,0
1024,1
1025,0
1026,0
1027,0
1028,0
1029,0
1030,1
1031,0
1032,1
1033,1
1034,0
1035,0
1036,0
1037,0
1038,0
1039,0
1040,0
1041,0
1042,1
1043,0
1044,0
1045,1
1046,0
1047,0
1048,1
1049,1
1050,0
1051,1
1052,1
1053,0
1054,1
1055,0
1056,0
1057,1
1058,0
1059,0
1060,1
1061,1
1062,0
1063,0
1064,0
1065,0
1066,0
1067,1
1068,1
1069,0
1070,1
1071,1
1072,0
1073,0
1074,1
1075,0
1076,1
1077,0
1078,1
1079,0
1080,1
1081,0
1082,0
1083,0
1084,0
1085,0
1086,0
1087,0
1088,0
1089,1
1090,0
1091,1
1092,1
1093,0
1094,0
1095,1
1096,0
1097,0
1098,1
1099,0
1100,1
1101,0
1102,0
1103,0
1104,0
1105,1
1106,1
1107,0
1108,1
1109,0
1110,1
1111,0
1112,1
1113,0
1114,1
1115,0
1116,1
1117,1
1118,0
1119,1
1120,0
1121,0
1122,0
1123,1
1124,0
1125,0
1126,0
1127,0
1128,0
1129,0
1130,1
1131,1
1132,1
1133,1
1134,0
1135,0
1136,0
1137,0
1138,1
1139,0
1140,1
1141,1
1142,1
1143,0
1144,0
1145,0
1146,0
1147,0
1148,0
1149,0
1150,1
1151,0
1152,0
1153,0
1154,1
1155,1
1156,0
1157,0
1158,0
1159,0
1160,1
1161,0
1162,0
1163,0
1164,1
1165,1
1166,0
1167,1
1168,0
1169,0
1170,0
1171,0
1172,1
1173,0
1174,1
1175,1
1176,1
1177,0
1178,0
1179,0
1180,0
1181,0
1182,0
1183,1
1184,0
1185,0
1186,0
1187,0
1188,1
1189,0
1190,0
1191,0
1192,0
1193,0
1194,0
1195,0
1196,1
1197,1
1198,0
1199,0
1200,0
1201,1
1202,0
1203,0
1204,0
1205,1
1206,1
1207,1
1208,0
1209,0
1210,0
1211,0
1212,0
1213,0
1214,0
1215,0
1216,1
1217,0
1218,1
1219,0
1220,0
1221,0
1222,1
1223,0
1224,0
1225,1
1226,0
1227,0
1228,0
1229,0
1230,0
1231,0
1232,0
1233,0
1234,0
1235,1
1236,0
1237,1
1238,0
1239,1
1240,0
1241,1
1242,1
1243,0
1244,0
1245,0
1246,1
1247,0
1248,1
1249,0
1250,0
1251,1
1252,0
1253,1
1254,1
1255,0
1256,1
1257,1
1258,0
1259,1
1260,1
1261,0
1262,0
1263,1
1264,0
1265,0
1266,1
1267,1
1268,1
1269,0
1270,0
1271,0
1272,0
1273,0
1274,1
1275,1
1276,0
1277,1
1278,0
1279,0
1280,0
1281,0
1282,0
1283,1
1284,0
1285,0
1286,0
1287,1
1288,0
1289,1
1290,0
1291,0
1292,1
1293,0
1294,1
1295,0
1296,0
1297,0
1298,0
1299,0
1300,1
1301,1
1302,1
1303,1
1304,1
1305,0
1306,1
1307,0
1308,0
1309,0
Pclass,Sex,SibSp,Parch,Embarked,Survived,decade
3,male,0,0,Q,0,30th
3,female,1,0,S,1,40th
2,male,0,0,Q,0,60th
3,male,0,0,S,0,20th
3,female,1,1,S,1,20th
3,male,0,0,S,0,10th