factmac

factmac

Description

The factmac action learns a factorization machine model. Factorization machines are a general predictor like support vector machines (SVMs) and tensor factorization models. They are particularly effective for high-dimensional sparse data, such as recommendation systems.

Settings
ParameterDescription
tableSpecifies the input data table.
targetSpecifies the target variable for the model.
inputsSpecifies the variables to be used in the training.
nominalsSpecifies the nominal variables to be used in the training.
nFactorsSpecifies the number of factors to be estimated. Default is 5.
maxIterSpecifies the maximum number of iterations. Default is 30.
learnStepSpecifies the learning step size for the optimization. Default is 0.001.
outModelSpecifies the output data table in which to save the estimated factorization machine parameters.
outputSpecifies the output data table in which to save the scored observations.
saveStateSpecifies the output data table in which to save the state of the factorization machine for future scoring.
nonNegativeWhen set to True, performs nonnegative factorization. Default is FALSE.
applyRowOrderSpecifies that the action uses a prespecified row ordering (requires orderby/groupby in partition).
seedSpecifies the seed value for random number generation.
Data Preparation View data prep sheet
Creation of sparse rating data

Creates a dataset 'ratings' simulating user-item interactions often used in recommendation systems.

Copied!
1DATA mycas.ratings;
2 INPUT user item rating;
3 DATALINES;
41 1 5
51 2 3
61 4 2
72 1 4
82 3 2
92 5 5
103 2 5
113 3 3
123 6 4
134 1 2
144 4 5
154 6 1
16;
17RUN;

Examples

Trains a factorization machine model using default settings on the ratings data.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 factmac.factmac /
3 TABLE='ratings',
4 target='rating',
5 inputs={'user', 'item'},
6 nominals={'user', 'item'};
7RUN;
Result :
The action produces a model summary and iteration history showing the training error.

Trains a model with specific factors, iteration limits, learning step, and saves the model and scoring state.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 factmac.factmac /
3 TABLE='ratings',
4 target='rating',
5 inputs={'user', 'item'},
6 nominals={'user', 'item'},
7 nFactors=10,
8 maxIter=50,
9 learnStep=0.005,
10 outModel={name='factmac_factors', replace=TRUE},
11 saveState={name='factmac_state', replace=TRUE},
12 OUTPUT={casOut={name='scored_ratings', replace=TRUE}, copyVars={'user', 'item', 'rating'}};
13RUN;
Result :
Generates 'factmac_factors' containing model parameters, 'factmac_state' for future scoring, and 'scored_ratings' with predictions.

FAQ

What is the primary purpose of the factmac action?
How can I specify the number of factors to be estimated?
Which parameter allows me to control the maximum number of iterations?
How do I perform nonnegative factorization with the factmac action?
What is the function of the learnStep parameter?
How can I save the estimated model parameters to a CAS table?
Is it possible to generate SAS score code using this action?
How can I partition the input data into training, validation, and testing sets?
What does the saveState parameter do?
How do I specify the target variable for the factorization machine?