| |
Methods defined here:
- __init__(self, object=None, ratings_data=None, weights_data=None, bias_data=None, userid_column=None, itemid_column=None, rating_column=None, topk=3, ratings_data_sequence_column=None, weights_data_sequence_column=None, bias_data_sequence_column=None, ratings_data_partition_column='1', ratings_data_order_column=None, weights_data_order_column=None, bias_data_order_column=None)
- DESCRIPTION:
The KNNRecommenderPredict function applies the model output by the KNNRecommender
function to predict the ratings or preferences that users would assign to
entities like books, songs, movies and other products.
PARAMETERS:
object:
Optional Argument, when 'weights_data' and 'bias_data' provided.
Specifies the instance of KNNRecommender containing the
weights_data and bias_data.
ratings_data:
Required Argument.
Specifies the teradataml DataFrame containing the user ratings.
ratings_data_partition_column:
Optional Argument.
Specifies the partition By columns for ratings_data.
Values to this argument can be provided as list, if multiple columns
are used for partition.
Default Value: 1
Types: str OR list of Strings (str)
ratings_data_order_column:
Optional Argument.
Specifies Order By columns for ratings_data.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
weights_data:
Optional Argument.
Specifies the teradataml DataFrame (produced by KNNRecommender function)
containing the interpolation weights. Optional argument if
object is provided. If the value is provided along with object this value
will be overwritten with the weigths_data of object value.
weights_data_order_column:
Optional Argument.
Specifies Order By columns for weights_data.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
bias_data:
Optional Argument.
Specifies the teradataml DataFrame (produced by KNNRecommender function)
containing the global, user, and item bias statistics. Optional argument if
object is provided. If the value is provided along with object this value
will be overwritten with the bias_data of object value.
bias_data_order_column:
Optional Argument.
Specifies Order By columns for bias_data.
Values to this argument can be provided as a list, if multiple
columns are used for ordering.
Types: str OR list of Strings (str)
userid_column:
Optional Argument.
Specifies the user id column in the rating table. The default is the first
column in the rating table.
Types: str OR list of Strings (str)
itemid_column:
Optional Argument.
Specifies the item id column in the rating table. The default is the second
column in the rating table.
Types: str OR list of Strings (str)
rating_column:
Optional Argument.
Specifies the rating column in the rating table. The default is the third
column in the rating table.
Types: str OR list of Strings (str)
topk:
Optional Argument.
Specifies the number of items to recommend for each user. The topk highest-rated
items are recommended.
Default Value: 3
Types: int
ratings_data_sequence_column:
Optional Argument.
Specifies the list of column(s) that uniquely identifies each row of
the input argument "ratings_data". The argument is used to ensure
deterministic results for functions which produce results that vary
from run to run.
Types: str OR list of Strings (str)
weights_data_sequence_column:
Optional Argument.
Specifies the list of column(s) that uniquely identifies each row of
the input argument "weights_data". The argument is used to ensure
deterministic results for functions which produce results that vary
from run to run.
Types: str OR list of Strings (str)
bias_data_sequence_column:
Optional Argument.
Specifies the list of column(s) that uniquely identifies each row of
the input argument "bias_data". The argument is used to ensure
deterministic results for functions which produce results that vary
from run to run.
Types: str OR list of Strings (str)
RETURNS:
Instance of KNNRecommenderPredict.
Output teradataml DataFrames can be accessed using attribute
references, such as KNNRecommenderPredictObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
result
RAISES:
TeradataMlException
EXAMPLES:
# Load the data to run the example
load_example_data("knnrecommenderpredict", ["ml_ratings", "ml_ratings_10"])
# Create teradataml DataFrame objects.
ml_ratings = DataFrame.from_table("ml_ratings")
# Example 1 - Train the KNN Recommender system on the user ratings data
knn_recommender_out = KNNRecommender(rating_table = ml_ratings,
userid_column = "userid",
itemid_column = "itemid",
rating_column = "rating"
)
# ml_ratings_10 table has movie ratings from a subset of users from the ml_ratings
# table. The ml_bias and ml_weights table has the weights and bias values
# from the trained KNN Recommender model.
ml_weights = knn_recommender_out.weight_model_table
ml_bias = knn_recommender_out.bias_model_table
# Here "bias_data" and "weights_data" have been made optional with the argument "object"
# having the knn_recommender_out output object
# Create teradataml DataFrame objects.
ml_ratings_10 = DataFrame.from_table("ml_ratings_10")
knn_recommender_predict_out = KNNRecommenderPredict(
object = knn_recommender_out,
ratings_data = ml_ratings_10,
ratings_data_partition_column = "userid",
topk = 5
)
# Print the result DataFrame
print(knn_recommender_predict_out)
# Use the generated model to make user rating predictions. Here the argument "object"
# has been made optional with the specification of both the arguments "bias_data" and
# "weights_data"
knn_recommender_predict_out2 = KNNRecommenderPredict(
ratings_data = ml_ratings_10,
ratings_data_partition_column = "userid",
weights_data = ml_weights,
bias_data = ml_bias,
topk = 5
)
# Print the result DataFrame
print(knn_recommender_predict_out2)
- __repr__(self)
- Returns the string representation for a KNNRecommenderPredict class instance.
|