Skip to main content
Ctrl+K
LensKit 2025.3.0a3.dev293+g04151dfb documentation - Home LensKit 2025.3.0a3.dev293+g04151dfb documentation - Home
  • User Guide
  • API Reference
  • Release Notes
  • Indices
  • GitHub
  • Mastodon
  • User Guide
  • API Reference
  • Release Notes
  • Indices
  • GitHub
  • Mastodon

Section Navigation

Core

  • Data Abstractions
    • Basic Data Types
    • lenskit.data.Dataset
    • lenskit.data.EntitySet
    • lenskit.data.AttributeSet
    • lenskit.data.RelationshipSet
    • lenskit.data.MatrixRelationshipSet
    • lenskit.data.CSRStructure
    • lenskit.data.DatasetBuilder
    • lenskit.data.from_interactions_df
    • lenskit.data.load_movielens
    • lenskit.data.load_movielens_df
    • lenskit.data.ItemList
    • lenskit.data.ItemListCollection
    • lenskit.data.ItemListCollector
    • lenskit.data.ListILC
    • lenskit.data.UserIDKey
    • lenskit.data.GenericKey
    • lenskit.data.MutableItemListCollection
    • lenskit.data.RecQuery
    • lenskit.data.QueryInput
    • lenskit.data.schema
    • lenskit.data.Vocabulary
    • lenskit.data.matrix.SparseRowType
    • lenskit.data.matrix.SparseIndexType
    • lenskit.data.matrix.SparseRowArray
  • Pipeline API
    • lenskit.pipeline.Pipeline
    • lenskit.pipeline.PipelineBuilder
    • lenskit.pipeline.PipelineState
    • lenskit.pipeline.Node
    • lenskit.pipeline.Lazy
    • lenskit.pipeline.PipelineCache
    • lenskit.pipeline.Component
    • lenskit.pipeline.RecPipelineBuilder
    • lenskit.pipeline.topn_pipeline
    • lenskit.pipeline.predict_pipeline
    • lenskit.pipeline.PipelineConfig
  • Operation Functions
  • Diagnostic APIs
  • Model Training
  • Model State
    • lenskit.state.ParameterContainer

Components

  • lenskit.basic
    • lenskit.basic.bias
    • lenskit.basic.candidates
    • lenskit.basic.composite
    • lenskit.basic.history
    • lenskit.basic.popularity
    • lenskit.basic.random
    • lenskit.basic.topn
  • lenskit.stochastic
  • lenskit.knn
    • lenskit.knn.item
    • lenskit.knn.user
  • lenskit.als
  • lenskit.flexmf
  • lenskit.sklearn
    • lenskit.sklearn.svd
  • lenskit.funksvd
  • lenskit.implicit
  • lenskit.hpf

Evaluation

  • Batch Operations
    • lenskit.batch.BatchPipelineRunner
    • lenskit.batch.BatchResults
    • lenskit.batch.predict
    • lenskit.batch.recommend
    • lenskit.batch.InvocationSpec
  • Metrics and Analysis
    • lenskit.metrics.Metric
    • lenskit.metrics.ListMetric
    • lenskit.metrics.GlobalMetric
    • lenskit.metrics.MetricFunction
    • lenskit.metrics.RankingMetricBase
    • lenskit.metrics.RunAnalysis
    • lenskit.metrics.RunAnalysisResult
    • lenskit.metrics.ListLength
    • lenskit.metrics.TestItemCount
    • lenskit.metrics.NDCG
    • lenskit.metrics.RBP
    • lenskit.metrics.Precision
    • lenskit.metrics.Recall
    • lenskit.metrics.RecipRank
    • lenskit.metrics.MeanPopRank
    • lenskit.metrics.RMSE
    • lenskit.metrics.MAE
  • Data Splitting
    • lenskit.splitting.TTSplit
    • lenskit.splitting.split_global_time
    • lenskit.splitting.crossfold_users
    • lenskit.splitting.sample_users
    • lenskit.splitting.LastFrac
    • lenskit.splitting.LastN
    • lenskit.splitting.SampleFrac
    • lenskit.splitting.SampleN
    • lenskit.splitting.crossfold_records
    • lenskit.splitting.sample_records

Implementation Helpers

  • lenskit.logging
    • lenskit.logging.config
    • lenskit.logging.monitor
    • lenskit.logging.processors
    • lenskit.logging.progress
    • lenskit.logging.resource
    • lenskit.logging.stopwatch
    • lenskit.logging.tasks
    • lenskit.logging.tracing
    • lenskit.logging.worker
  • lenskit.math
    • lenskit.math.solve
    • lenskit.math.sparse
  • lenskit.parallel
    • lenskit.parallel.config
    • lenskit.parallel.invoker
    • lenskit.parallel.pool
    • lenskit.parallel.ray
    • lenskit.parallel.sequential
    • lenskit.parallel.serialize
    • lenskit.parallel.worker
  • lenskit.random
  • lenskit.stats
  • lenskit.torch
  • API Reference
  • Data Splitting
  • lenskit.splitting.SampleN

lenskit.splitting.SampleN#

class lenskit.splitting.SampleN(n, rng=None)#

Bases: HoldoutMethod

Randomly select a fixed number of test rows per user/item.

Stability:
Caller (see Stability Levels).
Parameters:
  • n (int) – The number of test items to select.

  • rng (Generator) – The random number generator or seed (see Random Seeds).

__init__(n, rng=None)#
Parameters:
  • n (int)

  • rng (int | Sequence[int] | SeedSequence | Generator | BitGenerator | None)

Methods

__init__(n[, rng])

Attributes

n

rng

previous

lenskit.splitting.SampleFrac

next

lenskit.splitting.crossfold_records

On this page
  • SampleN
    • SampleN.__init__()

This Page

  • Show Source

© Copyright 2018–2025 Drexel University, Boise State University, and collaborators.

LensKit version 2025.3.0a3.dev293+g04151dfb.

This material is based upon work supported by the National Science Foundation under Grant No. IIS 17-51278. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation, Drexel University, or Boise State University.