public class DataModel extends Object implements Serializable
Constructor and Description |
---|
DataModel(DataSet dataset)
This constructor initializes the DataModel with the contents of the given DataSet.
|
Modifier and Type | Method and Description |
---|---|
void |
addRating(int userIndex,
int itemIndex,
double rating)
Adds a single (training) rating to the DataModel.
|
void |
addTestRating(int testUserIndex,
int testItemIndex,
double rating)
Adds a single test rating to the DataModel.
|
int |
findItemIndex(String itemId)
Finds the itemIndex of an Item at the Items' array given its unique id.
|
int |
findTestItemIndex(String itemId)
Finds the testItemIndex of a TestItem at the TestItem' array given its unique id.
|
int |
findTestUserIndex(String userId)
Finds the testUserIndex of a TestUser at the TestUsers' array given his/her unique id.
|
int |
findUserIndex(String userId)
Finds the userIndex of a User at the Users' array given his/her unique id.
|
DataBank |
getDataBank()
Gets the DataBank instance that stores heterogeneous information related to the DataModel.
|
Item |
getItem(int itemIndex)
Gets an Item by its index.
|
Item[] |
getItems()
Gets the array of Items.
|
double |
getMaxRating()
Gets the maximum (training) rating.
|
double |
getMaxTestRating()
Gets the maximum test rating.
|
double |
getMinRating()
Gets the minimum (training) rating.
|
double |
getMinTestRating()
Gets the minimum test rating.
|
int |
getNumberOfItems()
Gets the number of items contained in the DataModel.
|
int |
getNumberOfRatings()
Return the number of ratings contained in the DataModel.
|
int |
getNumberOfTestItems()
Gets the number of test items contained in the DataModel.
|
int |
getNumberOfTestRatings()
Return the number of test ratings contained in the DataModel.
|
int |
getNumberOfTestUsers()
Gets the number of test users contained in the DataModel.
|
int |
getNumberOfUsers()
Gets the number of users contained in the DataModel.
|
double |
getRatingAverage()
Gets the average of (training) ratings.
|
TestItem |
getTestItem(int testItemIndex)
Gets a TestItem by its index.
|
TestItem[] |
getTestItems()
Gets the array of TestItems.
|
double |
getTestRatingAverage()
Gets the average of test ratings.
|
TestUser |
getTestUser(int testUserIndex)
Gets a TestUser by his/her test index.
|
TestUser[] |
getTestUsers()
Gets the array of TestUsers.
|
User |
getUser(int userIndex)
Gets an User by his/her index.
|
User[] |
getUsers()
Gets the array of Users.
|
static DataModel |
load(String filePath)
Loads a DataModel from a previously serialized file (see save() method).
|
void |
save(String filePath)
Saves the content of the DataModel in a serialized file.
|
String |
toString() |
public DataModel(DataSet dataset)
dataset
- DataSet to be added to the DataModel.public void save(String filePath) throws IOException
filePath
- Path where the file will be stored, filename and extension should be included
in the path.IOException
- When the file is not accessible by the system with write permissions.public static DataModel load(String filePath) throws IOException, ClassNotFoundException
filePath
- Path where the file will be loaded, filename and extension should be included
in the path.IOException
- When the file is not accessible by the system with reading permissions.ClassNotFoundException
- When the file exist and is accessible, but it doesn't contains a
valid instance.public void addTestRating(int testUserIndex, int testItemIndex, double rating)
testUserIndex
- Index of the TestUser at the DataModeltestItemIndex
- Index of the TestItem at the DataModelrating
- Rating valuepublic void addRating(int userIndex, int itemIndex, double rating)
userIndex
- Index of the User at the DataModelitemIndex
- Index of the Item at the DataModelrating
- Rating valuepublic User[] getUsers()
public TestUser[] getTestUsers()
public Item[] getItems()
public TestItem[] getTestItems()
public DataBank getDataBank()
public int getNumberOfUsers()
public User getUser(int userIndex)
userIndex
- Index of the User in the Users' array inside the DataModel.public int findUserIndex(String userId)
userId
- User id to be searched.public int getNumberOfTestUsers()
public TestUser getTestUser(int testUserIndex)
testUserIndex
- Index of the TestUser in the TestUsers' array inside the DataModel.public int findTestUserIndex(String userId)
userId
- User id to be searched.public int getNumberOfItems()
public Item getItem(int itemIndex)
itemIndex
- Index of the Item in the Items' array inside the DataModel.public int findItemIndex(String itemId)
itemId
- Item id to be searched.public int getNumberOfTestItems()
public TestItem getTestItem(int testItemIndex)
testItemIndex
- Index of the TestItem in the TestItem' array inside the DataModel.public int findTestItemIndex(String itemId)
itemId
- Item id to be searched.public double getMinRating()
public double getMaxRating()
public double getRatingAverage()
public double getMinTestRating()
public double getMaxTestRating()
public double getTestRatingAverage()
public int getNumberOfRatings()
public int getNumberOfTestRatings()
Copyright © 2020. All rights reserved.