Skip to content

Commit

Permalink
Merge pull request #3563 from rcurtin/py-split-doc-fix
Browse files Browse the repository at this point in the history
Fix call to preprocess_split() in generated documentation.
  • Loading branch information
rcurtin committed Nov 27, 2023
2 parents e92eb6d + 3dfccb2 commit bbde929
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
### mlpack ?.?.?
###### ????-??-??
* Fix `preprocess_split()` call in documentation for `LinearRegression` and
`AdaBoost` Python classes (#3563).

### mlpack 4.3.0
###### 2023-11-22
###### 2023-11-27
* Fix include ordering issue for `LinearRegression` (#3541).

* Fix L1 regularization in case where weight is zero (#3545).
Expand Down
13 changes: 7 additions & 6 deletions src/mlpack/bindings/python/print_doc_functions_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,13 @@ inline std::string SplitTrainTest(const std::string& datasetName,
const std::string& testLabels,
const std::string& splitRatio)
{
std::string splitString = ">>> ";
splitString += testDataset + ", " + testLabels + ", ";
splitString += trainDataset + ", " + trainLabels;
splitString += " = ";
splitString += "preprocess_split(input_=" + datasetName + ", input_labels=";
splitString += labelName + ", test_ratio=" + splitRatio + ")";
std::string splitString;
splitString += ">>> d = preprocess_split(input_=" + datasetName + ", input_labels=";
splitString += labelName + ", test_ratio=" + splitRatio + ")\n";
splitString += ">>> " + trainDataset + " = d['training']\n";
splitString += ">>> " + trainLabels + " = d['training_labels']\n";
splitString += ">>> " + testDataset + " = d['test']\n";
splitString += ">>> " + testLabels + " = d['test_labels']";
return splitString;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ BINDING_EXAMPLE(
GET_DATASET("X", "https://example.com") + "\n" +
GET_DATASET("y", "https://example.com") + "\n" +
SPLIT_TRAIN_TEST("X", "y", "X_train", "y_train", "X_test", "y_test",
"0.2") + "\n" +
CREATE_OBJECT("model", "linear_regression") + "\n" +
CALL_METHOD("model", "train", "training", "X_train",
"training_responses", "y_train"));
"0.2") + "\n" +
CREATE_OBJECT("lr", "linear_regression") + "\n" +
CALL_METHOD("lr", "train", "training", "X_train", "training_responses",
"y_train"));

// See also...
BINDING_SEE_ALSO("Linear/ridge regression tutorial",
"@doc/tutorials/linear_regression.md");
"@doc/tutorials/linear_regression.md");

PARAM_MATRIX_IN_REQ("training", "Matrix containing training set X (regressors).",
"t");
Expand Down

0 comments on commit bbde929

Please sign in to comment.