Exemplo n.º 1
0
 def test_load_data_small(self):
     # only run data download tests 20% of the time to speed up frequent testing
     random.seed(time.time())
     if random.random() > 0.8:
         data = netflix.load_data_small()
         self.assertEqual(len(data), 607803)
Exemplo n.º 2
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Example for Bayesian Personalized Ranking with Netflix dataset"""

import cornac
from cornac.data import Reader
from cornac.datasets import netflix
from cornac.eval_methods import RatioSplit

ratio_split = RatioSplit(
    data=netflix.load_data_small(reader=Reader(bin_threshold=1.0)),
    test_size=0.1,
    rating_threshold=1.0,
    exclude_unknowns=True,
    verbose=True)

most_pop = cornac.models.MostPop()
bpr = cornac.models.BPR(k=10,
                        max_iter=100,
                        learning_rate=0.001,
                        lambda_reg=0.01,
                        verbose=True)

auc = cornac.metrics.AUC()
rec_20 = cornac.metrics.Recall(k=20)
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
Example for Bayesian Personalized Ranking with Netflix dataset (subset)

@author: Quoc-Tuan Truong <*****@*****.**>
"""

import cornac
from cornac.datasets import netflix
from cornac.eval_methods import RatioSplit

ratio_split = RatioSplit(data=netflix.load_data_small(),
                         test_size=0.1,
                         rating_threshold=1.0,
                         exclude_unknowns=True,
                         verbose=True)

bpr = cornac.models.BPR(k=10,
                        max_iter=100,
                        learning_rate=0.01,
                        lambda_reg=0.01)

auc = cornac.metrics.AUC()
rec_20 = cornac.metrics.Recall(k=20)

exp = cornac.Experiment(eval_method=ratio_split,
                        models=[bpr],
                        metrics=[auc, rec_20],
                        user_based=True)
exp.run()