/** <p>Tests {@link InverseUserFrequency}.</p> */
public final class InverseUserFrequencyTest extends TransformTestCase {
public void testIUF() throws Exception {
DataModel dataModel = getDataModel(
new long[] {1, 2, 3, 4, 5},
new Double[][] {
{0.1},
{0.2, 0.3},
{0.4, 0.5, 0.6},
{0.7, 0.8, 0.9, 1.0},
{1.0, 1.0, 1.0, 1.0, 1.0},
});
InverseUserFrequency iuf = new InverseUserFrequency(dataModel, 10.0);
PreferenceArray user5Prefs = dataModel.getPreferencesFromUser(5);
for (int i = 0; i < 5; i++) {
Preference pref = user5Prefs.get(i);
assertNotNull(pref);
assertEquals(Math.log(5.0 / (double) (5 - i)) / Math.log(iuf.getLogBase()),