# Predict best price using neural network?

Our customer runs a tour agency. He has an excel spreadsheet containing the following information for people that have contacted them:

Customer name, country, tour duration (requested by customer), tour date, number of people in the tour (usually from 1 to 3), price given to the customer, answer: accepted/rejected (indicates if customer accepted or rejected the price given by the tour agency).

My customer wants a predictor or tool that can let him enter the details given by future customers, e.g:

Number of participants, Tour duration, Country (not sure if necessary?)

And the system will return the best price to charge the customer (so he won't reject the proposal but pay the maximum possible).

Another option would be that the tour agency owner will enter the price and the system will answer "Customer will accept that price" or "Customer will reject that price".

Is this even possible? I think it may be done using neural networks trained with the previous answers from customers that the tour agency owner has in his excel spreadsheet?

This is possible.... but there's no reason to use a neural network! Your best bet on a problem like this is likely to use a logistical regression for the yes/no aspect of the question and a linear regression (or combination of linear regressions) to answer the pricing question - there are also ways of simply using linear regressions and setting up cutoffs to answer the yes/no question.

The reality is that the accuracy of such a model/series of models would depend entirely on the quality and quantity of the data, but it's unlikely that in this case a neural network would provide a better result than smart usage of simpler models.

• Thanks, can you provide more details about how to use logistical regression? I don't know where to start to do this – Stephen H. Anderson May 13 '19 at 23:14
• @StephenH.Anderson I think a more conventional spelling would be "logistic" regression (they are a generalised form of linear regressions). they are very common and easy to fit, just google around or questions like stackoverflow.com/q/12146914/1358308 or maybe search on stats.stackexchange.com – Sam Mason May 16 '19 at 22:01
• Everything that @sam-mason said - thanks for responding (forgot to check if there had been responses) – skant May 17 '19 at 23:29

Background Before Attacking the Problem

A process, whether done with a pencil and paper, entirely mentally, through a custom algorithm, or using a more general AI approach, that selects best price for a product or service is an optimization process rather than a prediction one. Prediction is the process of using current state and possibly the historic trend leading to it to determine the distribution of probabilities of a future state.

Pricing is an ongoing optimization problem because the price can be set and changed during the market period. Setting a price and leaving it that way for the duration of a business is a bad idea. If the algorithm applied adapts to changes in the market, such as consumer attitudes, branding goodwill, changes in the use of the product or service, cost of procurement, or the emergence of similar vendors, then it would be a continuous learning system.

Note that continuous learning systems must either run in parallel with the actual pricing process or be reentrant so that it can share the same computing hardware, however, it need not be of the reinforcement learning type, which assumes a sequence of actions based on a distribution of expectations associated with each option. If the Markov property is applied, the actions are based only on the state of the system at the time of the choice. Otherwise, the history of states may be used in the determination of expectations and thus also action selection.

Also note that artificial networks are not the only type of continuous learning system. T-cells learn antigen indicators and provide adaptive immune response. Natural neurons do continuous and massively parallel learning. The very first artificial continuous learning system was probably Claude Shannon's electromechanical mouse, Theseus, that learned about a maze through trial and error, but could be dropped into the same maze it learned previously and continue learning where it left off. Thus, it was reentrant.

Considering Tourism

In the specific case, we have fields of records that could be used for basic data centered learning.

• Customer
• Country (presumably of the tour)
• Desired duration
• Start date
• Party size
• Quote
• Purchase outcome
• Either associated expense or margin (must be added)

The goal is to automate the quoting to optimize profit over time. The most primitive and perhaps easiest approach is using the most basic type of artificial network in common use, the multilayer Perceptron (now commonly called a FFN or feed forward network). In such a case, the following design features might be reasonably successful.

• Relatively shallow depth, maybe 4 or 5 layers for the first test run
• ReLU activation function for the cells of all but the last layer
• Stochastic gradient descent with back-propagation for learning
• Use the country, duration, start, party size, and quote as numeric input vectors (because the country correlates with price, it should be coded as a number and used)
• Dismiss the customer name as irrelevant, at least for this first phase of development, for reasons given below
• Use the purchase outcome as a training label
• Let the last layer be a single threshold layer
• Derive the loss function from the inverse of gain, which will require either an expense column or a margin column to be added into the spreadsheet and populated.

The total gain, if a margin column is added, would be

$$\mathcal{G} = \sum_{r = 1}^{N} o_r m_r \, \text{,}$$

where $$N$$ is the number of rows, $$o_r$$ is the outcome of 1 or 0 for paid and not paid respectively, and $$m_r$$ is the margin of the sale. The margin is the revenue via payment minus the associated expenses.

$$m = p - e$$

The inverse of what is inside the summation is the natural expression for the loss of each row.

$$\mathcal{l}_r = - o_r m_r$$

In using this approach, more rows in the spreadsheet, the more likely a function can be learned to provide an optimal price based on the data in the spreadsheet.

Note that this formulation dismisses marketing and other overhead expenses, so if applying this to decisioning for how to market, the $$p - e$$ representation would be more appropriate.

Limitations of MLPs and Future Directions

The result would be limited in that the trained network would then be a static function, which doesn't take into consideration many facets business intelligence involved in optimal pricing. Also note, again, that this is not a prediction function. It is a primitive optimization. The tuned pricing function that results from the training is optimized to the degree that a typical MLP, learning approach, and data set containing only the rows and columns noted can optimize.

• It does not attempt to differentiate culture using distributions of names, which would require much more data and a separate learning process to extract buying pattern features from an array of name codes for names with 1 to 6 parts.
• It does not consider how price variations, such as sales and other temporal pricing techniques, might further boost profit, which would require a recurrent network, such as an LSTM or GRU network.
• It does not use control of the price as a mechanism for using price variation to maximize profit, which would require the continuous learning type of system.
• It does not apply cognitive skills, which savvy business people use to further control price based on a number of marketing techniques, which would require a much higher level of AI with associative maps and probably emergent probabilistic rules.

Optimizing price opens up a can of worms, but the starting point may be to implement the initial MLP with a few layers and grow the skill level in automating these more advanced pricing strategies over time.

In summary, it is recommended that the AI vendor learn how to make the computer learn how to learn to price. In the most advanced stage, the learning is meta-meta-learning — three levels deep in learning or adaptation.

... [Want to better] understand two things ...

"the natural expression for the loss of each row" $$\mathcal{l}_r = − o_r m_r$$ is correct?

Yes. That is correct. $$\Delta \, \text{loss} = - \Delta \, \text{gain}$$. Because gradient descent uses gradients, the constant added to either a gain or a loss is irrelevant, thus the $$\Delta$$ symbol. Also, $$\Delta \, \text{advantage} = - \Delta \, \text{disadvantage}$$.

The outcome, $$o_r$$, is the switch that determines whether the margin is included for that row. If you code $$o_r$$ to be -1 for no sale and 1 for a sale, the "natural" aspect of the expression will be more obvious, but learning will proceed almost identically for either coding when seen as parameter adjustments to the cell inputs because all linear operations real numbers in gradient descent have no effect. Only when the numbers approach the range and accuracy limits of the variable type used in the actual software do linear operations matter at all. In those cases, you'll see the term saturation used, which is a term from control systems theory.

Also, error and accuracy have contrary relationship, but more complex than simple negation. Pain and pleasure are also contrary feedback signals that are used to incrementally "correct" the parameters of biological systems and some advance robotic systems, but that contrary relationship is much more complex than that of error and accuracy or the others.

For your initial project phase you need only know that $$g_r + \mathcal{l}_r = K$$ and the constant $$K$$ is not relevant in gradient descent. For those with calculus background, the differential equation resulting from the above is simply

$$d \mathcal{l} = - d \mathcal{g} \, \text{.}$$

... become a static function? The idea is that every time a customer contacts the vendor he uses the system to get the highest price the customer may accept and pay. After that he will insert the answer into the system (the system may have not accepted the price). So it will continue learning.

If you continue to add rows to the spreadsheet and retrain the network every day or every week, then the network parameter values will be completely replaced with new values by the retraining. After each training, the network behavior is static, fully defined by constants as parameter values.

As might be expected, the resulting retrained network has a higher probability of producing an improved pricing system than a degraded one relative to the previous training session. The pricing system will slowly improve, but not because of continuous learning. What would be occurring is the recreation of a static function as a trained network with continuously increasing data set size. Accuracy and reliability tend to improve as data set size increases.

Continuous learning is either reentrant, parallel, or both, meaning that the training does not start from scratch but the algorithms and/or parallel processes involved are designed to continue from any point and improve without fully discarding previous final or intermediate processing results.

Although the accuracy and reliability of the results of full retraining is better than training once and not retraining, the computational cost of starting from scratch each time is high. More importantly, it is primitive, and the technology goal is usually to move toward a system that truly replaces human pricing expertise, This first phase of such a project falls short of a system that integrates with marketing systems and learns how to put on sales or vary the price strategically in other ways to hook new customers, retain them, up sell, and augment offerings.

• Before the details of realizing deeplearning systems with GPUs are discussed, it's important to analyze first the underlying problem. Which is about price prediction with agents. In the literature, a large amount of papers was published about this subject and it would make sense to take a look into it. A good starting point for a query against Google Scholar is "price prediction datamining”. – Manuel Rodriguez May 14 '19 at 11:12
• Hi Douglas, thanks for your time and answer. I'm not AI expert so I'm rereading what you wrote. I didn't understand two things, "the natural expression for the loss of each row" lr=−ormr is correct? Also, why do you say it will become a static function? The idea is that everytime a customer contacts the vendor he uses the system to get the highest price the customer may accept and pay. After that he will insert the answer into the system (the system may have not accepted the price). So it will continue learning. The idea is to implement this as a web page (PHP). – Stephen H. Anderson May 14 '19 at 12:31

Price finding with artificial agents is on the first look a problem which has to do with calculating numbers. The price of the service is located somewhere in the range from 0 up to max and the system has to print out the value. Unfortunately, mathematics alone won't solve the issue. Because the price is only the result of a textual conversation and an information seeking process.

To grasp the complex situation of efficient markets and bid/ask relationships the underlying model has to be equipped with natural language processing capabilities. This will make the technical side more complex. A possible implementation is based on a price-negotiating prediction engine. That means, the agent is able to anticipate which price the customer will accept.

Such an engine is equal to a customer simulation. The customer and it's price sensitivity are modeled and this model is used to predict how the customer will decide. An easy to realize technique are behavior trees. • Manuel, sounds interesting, but, do you have any more details? – Stephen H. Anderson May 14 '19 at 12:20