Predict EC purchases from site visits
An online store sees many visits, and few of them end in a purchase. This guide trains a Fione model that gives each visit a probability of ending in a purchase. It goes from the download of an open dataset to a curl call of the served model.
Starting Fione from the published images and the general serving steps are in the practical guides overview. This page shows what is particular to this use case.
The business question
In the data used here, about 15% of the visits (sessions) end in a purchase. A store that knows, while a visit is going on, how likely it is to end in a purchase can act on it:
- offer help, free shipping or a coupon to visits that are likely to buy but hesitate;
- leave visits that will buy anyway undisturbed, and spend no discount on them;
- compare campaigns and pages by the share of visits that look likely to buy.
The model answers one question per visit: will this visit end in a purchase? It returns a yes/no answer and, more usefully, the probability of yes.
Get the data
The data is the Online Shoppers Purchasing Intention Dataset from the UCI Machine Learning Repository:
- Page: https://archive.ics.uci.edu/dataset/468/online+shoppers+purchasing+intention+dataset
- Creators: C. Sakar, Yomi Kastro (2018)
- DOI: 10.24432/C5F88Q
- Licence: Creative Commons Attribution 4.0 International (CC BY 4.0)
Attribution (UCI's citation): Sakar, C. & Kastro, Y. (2018). Online Shoppers Purchasing Intention Dataset [Dataset]. UCI Machine Learning Repository. https://doi.org/10.24432/C5F88Q. What we changed: we set the last 20 rows aside to try predictions on (see Prepare the CSV); no value was changed.
In an empty directory, download and unpack it:
curl -LO https://archive.ics.uci.edu/static/public/468/online+shoppers+purchasing+intention+dataset.zip
unzip online+shoppers+purchasing+intention+dataset.zipThe zip holds one file, online_shoppers_intention.csv (about 1 MB): comma-separated, with a header row, plain ASCII text (so also valid UTF-8). It has 12,330 rows and 18 columns, and no empty cells. According to UCI, each row is a session of a different user over one year.
The data
| Column | What it holds |
|---|---|
Administrative, Informational, ProductRelated | How many pages of each type the visitor viewed in the session |
Administrative_Duration, Informational_Duration, ProductRelated_Duration | The total time spent on each type of page |
BounceRates, ExitRates | Google Analytics bounce and exit rates of the pages viewed |
PageValues | Google Analytics page value of the pages viewed: the average value of a page that visitors viewed before completing a purchase |
SpecialDay | How close the visit is to a special day such as Mother's Day (0 to 1) |
Month | Month of the visit (Feb … Dec; the file has no January or April, and June is written June) |
OperatingSystems, Browser, Region, TrafficType | Codes for the visitor's system, browser, region and traffic source |
VisitorType | Returning_Visitor, New_Visitor or Other |
Weekend | Whether the visit was on a weekend (TRUE/FALSE) |
Revenue | The answer: whether the session ended in a purchase (TRUE/FALSE) |
Revenue is TRUE in 1,908 of the 12,330 sessions (15.5%). Three ordinary rows, a visit without a purchase, one with a purchase and a new visitor:
Administrative,Administrative_Duration,Informational,Informational_Duration,ProductRelated,ProductRelated_Duration,BounceRates,ExitRates,PageValues,SpecialDay,Month,OperatingSystems,Browser,Region,TrafficType,VisitorType,Weekend,Revenue
1,5,0,0,21,411.0833333,0.015789474,0.016140351,0,0,Nov,3,2,7,3,Returning_Visitor,FALSE,FALSE
3,16,3,86,15,2773.5,0,0.03,78.81172527,0,Dec,2,2,1,2,Returning_Visitor,FALSE,TRUE
3,100.5,0,0,95,1453.640882,0.002105263,0.012761333,0,0,Dec,2,2,3,2,New_Visitor,FALSE,FALSEPageValues is worth a look before training, because it is close to the answer. It is above 0 in 81% of the sessions that bought and in 11% of the others. Whether to keep a column like this depends on two things: is the value known at the moment you predict, and is it computed from the outcome you are predicting? UCI defines Page Value as "the average value for a web page that a user visited before completing an e-commerce transaction". We read this as a figure for each page, worked out from purchases that followed visits to that page, and so as a value that can be looked up for the pages a visitor has already viewed while the visit is going on. On that reading we keep it. UCI does not say whether a session's value leaves out that session's own purchase; if it does not, our first run's figures may be higher than a live site would get. Before you do the same, check two things on your site: that it can give, during a visit, the page value of each page viewed so far, and that this value comes from earlier visits, not from the visit you are predicting. If it cannot, leave PageValues out and expect results like our second run in Read the results.
Prepare the CSV
The file is already a CSV that Fione reads. The only step is to keep a few sessions apart, so that you can later predict rows the model never learned from. Keep the header and the last 20 rows in new-sessions.csv, and train on the other 12,310 rows in train.csv:
head -n 12311 online_shoppers_intention.csv > train.csv
{ head -n 1 online_shoppers_intention.csv; tail -n 20 online_shoppers_intention.csv; } > new-sessions.csvOf the 20 sessions set aside, 3 ended in a purchase.
Train the model
- On Projects, create a project (we named it
ecommerce-purchase) and open it. - Press Upload training data, choose
train.csvand press Upload and analyze. Data analysis shows 12,310 rows, 18 columns and 0% empty cells. - Under What do you want to predict?, choose
Revenue. Fione sees two values in it and suggests Classification. - Under Which columns should the model learn from?, all 17 other columns are checked; Fione unchecks none of them here. Leave them as they are. Fione reads
OperatingSystemsandRegionas Category andBrowserandTrafficTypeas Number, although all four are codes; we left that as it was. - Keep Classification under Prediction type.
- Under Maximum run time, choose 10 min (the default is 3 min; a longer run can find better models).
- Press Run.

When training ends, the page moves on to the Prediction summary.
Read the results

In our run:
- Rating: 2 out of 5. "On rows it did not learn from, the model was right about 90% of the time. Always guessing the most common answer would be right 85% of the time."
- Guide: "The model is a little better than guessing. More rows, more useful columns or a longer run may help."
- About this model: a blend of 7 models, 180 models tried, training time 6:16.
- Most useful inputs:
PageValues51%,Month16%,ExitRates6%,BounceRates4%,Administrative3%.
Why only 2 stars? The rating measures how far the model gets from "always guess no" (right 85% of the time here, because 85% of the visits do not buy) towards a perfect score. Unrounded, the model's Accuracy (on the Metrics tab, below) is 0.904 and always guessing no is right for 84.5% of the training rows, so the model covers (0.904 − 0.845) / (1 − 0.845) ≈ 0.38 of that distance. That is between 0.2 and 0.4, which gives 2 stars (How is the rating calculated? on the summary gives the formula and the bands). With a rare answer, the share of right answers says little. What a store needs is whether the model puts the visits that buy at the top, and how often it is right when it says "will buy".
Press Open advanced details and open the Metrics tab. It shows the figures measured on rows the models did not learn from. In our run:
- AUC 0.94 (0.5 is guessing, 1 is perfect): take one visit that bought and one that did not, and the model gives the one that bought the higher probability about 94% of the time.
- Top-10% lift 5.1: the 10% of visits the model rates most likely to buy bought 5.1 times as often as the average visit: about 79% of them, against 15% of all visits.
- Confusion matrix: of the 1,905 visits that bought, the model said
Truefor 1,160 (61%) and missed 745. Of the 10,405 that did not, it saidTruefor 437 (4%). Of the 1,597 visits it calledTrue, 1,160 (73%) did buy (Precision 0.726).
The True/False answer is the more likely of the two (the model's Choosing the predicted class setting is Most likely class). A store does not have to use that cut-off. It can rank visits by the probability and act on the top of the list, or pick its own cut-off: lower to reach more buyers at the cost of more offers to visits that would not buy, higher to make fewer, surer offers.
Most useful inputs is captioned "The columns that moved the predictions most, as a share of all the columns' effect." Fione works this out on its own shortly after training (about 8 seconds after it in our run), by explaining the model's predictions on rows of the training data. The page value of the pages viewed (PageValues) accounts for about half of the effect, then the month (Month), then the exit and bounce rates (ExitRates, BounceRates) and the number of administrative pages viewed (Administrative). Until that explanation is done, the summary shows a different list instead, captioned "The columns the model relied on most, as a share of all it used." and based on the training's own measure; that list stays on the Importance tab (in our run PageValues 46%, Month 15%, ExitRates 6%, ProductRelated_Duration 4%, ProductRelated 4%).
To see how much the model depends on PageValues, we trained a second model in the same way without it: it got 1 out of 5. Its accuracy, about 85%, is about the same as that of always guessing "no", but it still ranks visits: the 10% it rated most likely to buy bought about 3 times as often as the average visit (AUC 0.79, Top-10% lift 3.0). With PageValues the same figures were 0.94 and 5.1, so much of what the model can tell comes from that column.
Make predictions
Predict the 20 sessions you set aside:
- On the Prediction summary, press Make predictions.
- Choose
new-sessions.csvand press Upload. Fione says that "new-sessions" (20 rows) has every column the model needs, and marksRevenueas Not used by the model. Keep it checked under Columns in the result: it is copied next to the predictions, so you can compare them with what happened. - Press Predict. Predictions shows 20 rows × 21 columns and Download predict_new-sessions.csv.
predict is the answer, and p_True the probability of a purchase. Five of the 20 rows in our run:
| Row | PageValues | Month | p_True | predict | Revenue (what happened) |
|---|---|---|---|---|---|
| 1 | 0 | Nov | 0.057 | False | False |
| 2 | 0 | Nov | 0.30 | False | True |
| 3 | 1.58 | Nov | 0.58 | True | True |
| 4 | 78.8 | Dec | 0.61 | True | True |
| 10 | 3.69 | Dec | 0.64 | True | False |
Sorted by p_True, the 3 sessions that bought are among the top 4 of the 20; the other 16 sessions all have a p_True of 0.25 or less. Under the table, Why these predictions shows, for the first 5 rows, the columns that moved each prediction most. For row 1 it starts from an average prediction of 10.7%; PageValues (value 0.0) lowers the chance by 10.6 points and Month (Nov) raises it by 7.6 points, ending at 5.7%.
Serve it as an API
Under Serve it from your own system, press Download the serving bundle. Unpack it into a directory of its own and run the command shown on the card there, as in the overview. Use the name of your file; for our model:
unzip fione-serving-Revenue-model-2026-11-28-06-24-7.zip -d fione-serving-Revenue-model-2026-11-28-06-24-7
cd fione-serving-Revenue-model-2026-11-28-06-24-7
docker run --rm -p 8081:8080 -v "$PWD/model:/model:ro" ghcr.io/codelibs/fione-serving:snapshotIn another terminal, ask which columns the model expects:
curl -s localhost:8081/model{"names":["Administrative","Administrative_Duration","Informational","Informational_Duration","ProductRelated","ProductRelated_Duration","BounceRates","ExitRates","PageValues","SpecialDay","Month","OperatingSystems","Browser","Region","TrafficType","VisitorType","Weekend","Revenue"],
"domains":[null,null,null,null,null,null,null,null,null,null,["Aug","Dec","Feb","Jul","June","Mar","May","Nov","Oct","Sep"],null,null,null,null,["New_Visitor","Other","Returning_Visitor"],["False","True"],[false,true]],
"responseColumn":"Revenue","category":"Binomial","nclasses":2,"nfeatures":17, ...}Send rows 1 and 4 of new-sessions.csv, one visit without and one with a purchase:
curl -s -X POST localhost:8081/invocations -H 'Content-Type: application/json' -d '{"instances":[{"Administrative":1,"Administrative_Duration":5,"Informational":0,"Informational_Duration":0,"ProductRelated":21,"ProductRelated_Duration":411.0833333,"BounceRates":0.015789474,"ExitRates":0.016140351,"PageValues":0,"SpecialDay":0,"Month":"Nov","OperatingSystems":3,"Browser":2,"Region":7,"TrafficType":3,"VisitorType":"Returning_Visitor","Weekend":false},{"Administrative":3,"Administrative_Duration":16,"Informational":3,"Informational_Duration":86,"ProductRelated":15,"ProductRelated_Duration":2773.5,"BounceRates":0,"ExitRates":0.03,"PageValues":78.81172527,"SpecialDay":0,"Month":"Dec","OperatingSystems":2,"Browser":2,"Region":1,"TrafficType":2,"VisitorType":"Returning_Visitor","Weekend":false}]}'{"predictions":[{"label":false,"index":0,"class_probabilities":[0.9433868434999758,0.056613156500024235]},{"label":true,"index":1,"class_probabilities":[0.3855394427702635,0.6144605572297365]}]}class_probabilities follow the classes of Revenue in domains, false then true, so the second number is the probability of a purchase: 0.057 and 0.61, the same as p_True for these rows under Make predictions. A store's site would send the visit's values so far and act on that number.
Send Weekend as JSON true or false. In our run, the text "FALSE" or "TRUE" was not read as either value: both gave the same probability for row 1 (0.067), different from that of false (0.057) and true (0.061). The string "False" gave the same result as false, but JSON booleans are the safe choice.
From an AI tool
AI tools such as Claude and Codex can do the same through Fione's MCP endpoint: upload the CSV, train, read the results and predict. For a few visits, the predict tool takes rows like the two above and returns predict, p_False and p_True for each. Called directly over MCP for the model trained above, it returned the same probabilities as the API above (0.057 and 0.61). How to connect a client and what to ask is in Run the AutoML loop from an AI tool with MCP, and the predict tool in Predicting new rows.