Merge pull request #3398 from AdarshSantoria/cf

Update outdated codes in cf.md and datasetmapper.md
This commit is contained in:
Ryan Curtin
2023-02-11 12:12:38 -05:00
committed by GitHub
4 changed files with 23 additions and 15 deletions
+3
View File
@@ -1,5 +1,8 @@
### mlpack ?.?.?
###### ????-??-??
* Update outdated code in tutorials (#3398).
* Bugfix for non-square convolution kernels (#3376).
* Fix a few missing includes in `<mlpack.hpp>` (#3374).
+13 -10
View File
@@ -255,7 +255,7 @@ extern size_t rank;
// Build the CF object and perform the decomposition.
// The constructor takes a default-constructed factorizer, which, by default,
// is of type NMFALSFactorizer.
CF cf(data, NMFALSFactorizer(), neighborhood, rank);
CF cf(data, NMFPolicy(), neighborhood, rank);
// Store the results in this object.
arma::Mat<size_t> recommendations;
@@ -270,12 +270,15 @@ mlpack provides a number of existing factorizers which can be used in place of
the default `NMFALSFactorizer` (which is non-negative matrix factorization with
alternating least squares update rules). These include:
- `SVDBatchFactorizer`
- `SVDCompleteIncrementalFactorizer`
- `SVDIncompleteIncrementalFactorizer`
- `NMFALSFactorizer`
- `RegularizedSVD`
- `QUIC_SVD`
- `BatchSVDPolicy`
- `SVDCompletePolicy`
- `SVDIncompletePolicy`
- `NMFPolicy`
- `RegSVDPolicy`
- `QuicSVDPolicy`
- `BiasSVDPolicy`
- `SVDPlusPlusPolicy`
- `RandomizedSVDPolicy`
The `AMF` class has many other possibilities than those listed here; it is a
framework for alternating matrix factorization techniques. See the `AMF` class
@@ -297,7 +300,7 @@ extern size_t neighborhood;
extern size_t rank;
// Build the CF object and perform the decomposition.
CF cf(data, RegularizedSVD(), neighborhood, rank);
CFType cf(data, RegSVDPolicy(), neighborhood, rank);
// Store the results in this object.
arma::Mat<size_t> recommendations;
@@ -330,7 +333,7 @@ extern size_t rank;
// Build the CF object and perform the decomposition.
// The constructor takes a default-constructed factorizer, which, by default,
// is of type NMFALSFactorizer.
CF cf(data, NMFALSFactorizer(), neighborhood, rank);
CF cf(data, NMFPolicy(), neighborhood, rank);
const double prediction = cf.Predict(12, 50); // User 12, item 50.
```
@@ -356,7 +359,7 @@ extern size_t rank;
// Build the CF object and perform the decomposition.
// The constructor takes a default-constructed factorizer, which, by default,
// is of type NMFALSFactorizer.
CF cf(data, NMFALSFactorizer(), neighborhood, rank);
CF cf(data, NMFPolicy(), neighborhood, rank);
// References to W and H matrices.
const arma::mat& W = cf.W();
+5 -5
View File
@@ -43,7 +43,7 @@ function.
using namespace mlpack;
arma::mat data;
data::DatasetMapper info;
data::DatasetInfo info;
data::Load("dataset.csv", data, info);
```
@@ -155,8 +155,8 @@ std::cout << info.UnmapString(1, 2) << "\n";
This will print:
```
T
F
True
False
```
### `UnmapValue()`
@@ -168,8 +168,8 @@ The `UnmapValue()` function has the signature `UnmapValue(const std::string
- `dimension` is the dimension in which you want to find the mapped value
```c++
std::cout << info.UnmapValue("T", 2) << "\n";
std::cout << info.UnmapValue("F", 2) << "\n";
std::cout << info.UnmapValue("True", 2) << "\n";
std::cout << info.UnmapValue("False", 2) << "\n";
```
will produce:
+2
View File
@@ -283,6 +283,8 @@ class CFType
};
}; // class CFType
typedef CFType<> CF;
} // namespace mlpack
// Include implementation of templated functions.