Python如何使用Mymedialite
发布网友
发布时间:2022-03-03 13:04
我来回答
共1个回答
热心网友
时间:2022-03-03 14:33
首先你装个ironpython,然后就可以了啊。
给你几个例子程序。
Rating Prediction
#!/usr/bin/env ipy
import clr
clr.AddReference("MyMediaLite.dll")
from MyMediaLite import *
# load the data
train_data = IO.RatingData.Read("u1.base")
test_data = IO.RatingData.Read("u1.test")
# set up the recommender
recommender = RatingPrediction.UserItemBaseline() # don't forget ()
recommender.Ratings = train_data
recommender.Train()
# measure the accuracy on the test data set
print Eval.Ratings.Evaluate(recommender, test_data)
# make a prediction for a certain user and item
print recommender.Predict(1, 1) Item Prediction from Positive-Only Feedback#!/usr/bin/env ipy
import clr
clr.AddReference("MyMediaLite.dll")
from MyMediaLite import *
# load the data
train_data = IO.ItemData.Read("u1.base")
test_data = IO.ItemData.Read("u1.test")
# set up the recommender
recommender = ItemRecommendation.UserKNN() # don't forget ()
recommender.K = 20
recommender.Feedback = train_data
recommender.Train()
# measure the accuracy on the test data set
print Eval.Items.Evaluate(recommender, test_data, train_data)
# make a prediction for a certain user and item
print recommender.Predict(1, 1)
追问这两个程序貌似只能在ironPython3.0版本以上的实现~而ironPython官网版本只有2.7.5,能跑起来么?【Mymedialite库里头说跑不了,并且实践验证后也跑不了】,能请问你有python3.3.5版本或其他版本的Mymedialite应用例子么