Negotiation Assistant Bot of Pricing Prediction Based on Machine Learning

Artificial intelligence (AI) has been used to develop and advance numerous fields and industries, including finance, healthcare, education, transportation and more. However, in the business negotiation field, such as bargain, the AI has not yet exerted its power. In order to explore the application of AI into business negotiation, we have built an intelligent robot that can help customers that lack negotiation skills when bargaining in their shopping sceneries. This bot can make decision by itself via price prediction function implemented by machine learning algorithms and the tool of decision tree. As a result, our bot has got a positive performance during a used car trade. Although the algorithm of the project is relatively simple, its main contribution is to show the potential application of AI in the business negotiation. We believe that it can provide ideas and directions for the future development of business negotiation robot.

due to the complexity and randomness of human activity in real life, there are limited applications that combining machine learning with actual negotiation. In view of this, there is still a lot of exploration space in this field.

Introduction
Negotiation is an innate skill of human beings [8]. It plays important roles both in daily communications and trade cooperation. Therefore, it is necessary for everyone to master this kind of skills. However, on one hand, due to existing explicit and implicit rules underlying negotiations, it is not very easy to perform well in every situation, especially for the introverted persons. On the other, AI is very good at dealing with things that have clear rules but complicated processes. For AI, it can be programmed to respond to a set of assumptions and a set of data that have been presented in the past, thus predicting value and calculating these numbers in a more precise way than humans. This predicting data can be used as a standard reference for special features in negotiations. Consequently, it is a natural way to combine AI with negotiation, which can be used to automatically optimize people's decision when negotiating.
Here, due to there are many negotiation processes in the trading and the car price can be a predictable object affected by the car attributes, we choose the real problem of second-hand car transaction as the design basis. It can help the novice to make a decision when buying second-hand car and give the corresponding evaluation to the customer for feedback. The whole program can be divided into four parts: webpages, Price Bot, Advisor Bot and Judge Bot. As a result, our bot has got a positive performance during a used car trade. We believe that our research value is the primary combination of negotiation and machine learning algorithms. The significance of this research lies in: 1) providing an approximately real-time help to negotiators and giving them several negotiation ideas; 2) quickly finding the best alternative and telling them when to say "No" and go away; 3) realizing the preliminary combination of AI and negotiation.

Current Problems in Negotiation and Our Solutions
Negotiation is an important part of people's daily life. However, generally speaking, people cannot remember all the details in the process of negotiation, thus they will make wrong judgment or hesitate. In addition, many inexperienced people are lack of negotiation skills. In this second-hand car case, negotiators do not remember all the details of the car given by the shopper, including mileage, release, specific car name, etc. Maybe they only remember the price. Our solution is: first use our app to record these data, which will be put into the machine learning model after cleaning to get a fair market price, then we can find the best alternative which will be provided to negotiators through search algorithm. After that, implementing decision tree to help users negotiate. Therefore, our AI blocks many details that need to be memorized for the negotiator, offers a fair market price of the car to the negotiator as reference, provides suggestions for the negotiator and selects the best alternative for him.

Method and Data
The main body of the whole program is performed by Python. In the data collection part, Crawler based on Python's request library is used to grab data. The data come from several second-hand car transaction website, including http://www.guazi.com, http://www.kx.cn and http://www.che168.com. Html and JavaScript is used in the webpage and Python in the back end to process the corresponding Get and Post requests from the front end. In the data processing part, we use the Python's pandas library to convert the CSV file into data frame format, and process the discrete data, such as brand, car name, etc., into One-Hot code [9], which is the basis of later price prediction. In the part of price prediction, we use a variety of Machine Learning algorithms [10], including NN (Nearest Neighbor), KNN (K-Nearest Neighbor), SVM (Support Vector Machine), ANN (Artificial Neural Network). In the Judge Bot part, we use the "what-if" clause [11], and the decision tree provides the negotiation logic. In the Price Bot part, we wrote some basic functions to score the negotiation results of customers.

Car Selection
When the customer comes to the store, the sellers inquire about the customer's demand for the car and retrieve the matching vehicle in the warehouse through the search engine we built. At this time, customers will get the basic attribute information of the car, including the brand, model, service life, mileage, delivery date, insurance status, and after-sales guarantee. The output results will be ranked according to the priority of different attributes.

Price Prediction
After the customer gets this information, he can input the attributes of the car into the Price Bot. Price Bot will give a more radical recommendation price through ML algorithm. The price is to give the customer a basic price strategy to avoid losing too much in price negotiation.

Negotiations
After getting the recommended price, Advisor Bot will advise the users step by step according to the pre-made negotiation strategy. When the user fails to make a breakthrough in the price, Advisor Bot will suggest the user to do some tradeoff, such as upgrade the insurance level or get more after-sales support.

Final Judge
The Judge Bot will score the final deal, and users can decide whether to continue negotiations or direct deal based on their scores. In order to provide users with a reference standard, we will look for alternative options that match the needs of users in the trading market and score them with the same standard, so that users can have an alternative choice.

Data Collection
First, we should collect enough data for training the model, and I used a technique called Crawler, a practical tool based on python's library, to grip useful information from website [12]. Then I get two data sets for future use. One of them is a respectively large dataset containing 10K lines of data. This dataset will be used to train Machine Learning Model. Another is a small dataset including 1K lines of data. It acts as a warehouse of second-hand cars. So, we have two tables.
In each table, Columns are split into two parts: Attributes and Label. After training by dataset, Machine Learning Model will use Attributes to predict Label. All the columns except the Label are the related parameters of cars, such as brand, type, mileage, gear and so on, and the price's column becomes label. Each row represents one Sample. The dataset should be split into two parts: train set and test set. Generally, the size of train set is 70 percent of the whole dataset and the rest is test set.
To explain these two sets, let's make an analogy, if Machine Learning Model is a student, the train set is like a teacher and the test set like a final exam which will judge the accuracy of training result. The larger dataset is separated into four parameters: x_train (the intersection of train set and Attributes' columns), y_train (the intersection of train set and Label's column), x_test (the intersection of test set and Attributes' set) and y_test (intersection of test set and Label's column).
The larger dataset's division is shown in Figure 1.

Data Cleaning
Because the datasets are gripped from website, inevitably, there are a lot of dirty data in them. The accuracy will be intensively influenced by them. As a result, cleaning data is our next step. Dirty data have various types. The First is vacancy, and one of the solutions for these types of data is to fill in the blanks by calculating the average value of columns or just cut them out of the dataset. The former method is pragmatic but more time-consuming. The second problem is repetition. This will make the efficiency low. To solve it, people should delete superfluous data manually. The third problem is that outlier exists. For example, normal release is less than 3 liter, but it appears that some abnormal release data are larger than 50 liter which should be eliminated immediately. Another problem is that the data is not available. For example, there is a column of VolkswagenSatana1.5L34.2. This kind of data obviously combines brand, type, release, used years, mileage and other variables, so it's unusable. A simple way to deal with it is to delete this kind of data.

Data Transformation
The third step is to convert words into numbers, because Machine Learning Models have no way to recognize words. There are two ways to deal with text data. One is to number the words. The number increase by degrees. For second-hand cars, the "brand" data, Volkswagen number is 0, Honda number is 1 and so on. This method has some drawbacks. Also take "brand" as an example, it artificially defines the distance between two brands, e.g. Volkswagen is 0 and Hyundai is 100. Then Machine Learning Model will think that the distance between two brands is 100 (not actual 100, because there may be some algorithms to calculate the distance), but in fact, the two brands are only two symbols. Another method is to use One-Hot Code to process text. The basic idea is to record several values in the same size of columns. Assuming that there are three brands in used cars, Volkswagen, Honda and Hyundai, then the "brand" column is divided into three columns: Volkswagen is 001, Honda is 010 and Hyundai is 100. The advantage of this method is that the distance among all brands is equal, which means the distance between any two brands is equal. The disadvantage is that when there are too many different text attributes, the number of columns will increase rapidly, making the distribution of points extremely sparse, which is not conducive to training Machine Learning Model effectively. In our project, I use One-Hot Code to implement data transformation, because, after searching other experiment results, One-Hot Code performs better. The basic idea of the function that turns words into One-Hot Code is to put a standard line of data, such as Volkswagen, Santana, 1.5, 4, 3, 5.88 (brand, type, release, used years, mileage and price) in the first line of Data frame, a python's data type, to determine whether the first item in each column is a number (all real number). If so, skip that column. If not, turn an entire column into One-Hot Code. The Pandas library in Python has get dummies method that can break an entire column into One-Hot Code.

Webpages
The main function of webpages is to interact with users. Webpages are implemented in HTML, which is more convenient than python's console. The part of dynamic webpages is accomplished by JavaScript. The static pages use HTML tags and the interface is adjusted by Cascading Style Sheets (CSS). The interaction between the front end and the back end is realized by Flask, a python's library for web, using Form to transfer data. Users enter some parameters and select priorities, or say preference, at the front end, and these priorities are passed to the back end and recorded by our system, which determines the data filtering logic and the assistant strategy of Advisor Bot. The first page is that the seller will show to the user when the user comes to a used car store. The function of this page is to filter the car in the warehouse according to the user's priorities. The data in the warehouse comes from the smaller dataset. When a car is selected, the user will open his own webpage, input the relevant data of selected car, press the "Predict" button and then get a prediction (fair market) price, then he/she can "turn to Advisor Bot". The price prediction is achieved by Price Bot.

Price Bot
The function of Price Bot is to predict a fair market price according to the attributes entered by the user, give the corresponding Accuracy, and display the price on the webpage. We consider many algorithms that used in Machine Learning Model. Algorithms include Nearest Neighbor (NN), K-NN, Support Vector Machine (SVM) [13], Artificial Neural Network (ANN). After comparison, it is found that the Accuracy of ANN is the highest, but it takes 30 seconds, so our project adopts 5-NN algorithm (K = 5). Its Accuracy is lower compared to ANN, but it can give a result immediately and display the result on the webpage. After choosing the Machine Learning algorithm, input x_train and y_train as train set and x_test as test set into the Machine Learning Model. It will get the prediction set corresponding to x_test, and compare the prediction set with y_test, and then Accuracy and Square Error can be obtained. In order to predict price, my method is to add a line of Attributes to the last line of x_test, so that the last element of the prediction set is the fair market price. We will present this result to the user.

Advisor Bot
Advisor Bot is designed to help people who do not know any negotiation knowledge to get the best benefit in the transaction with the seller. We use Decision Tree to help users design negotiation ideas as shown in Figure 2 below. Firstly, Figure 2. Decision tree model. the offer in the figure is given by the seller and the recommend is the predicted price, or say fair market price. If offer < recommend, it means that the market average price is higher than the price given by the seller and the seller gives a good offer to user (the buyer). Advisor Bot will inform the user that he should accept the offer. If offer > recommend, it means that the seller gives a price higher than the market price. At this time, we will instruct users step by step to bargain. First, we will use an Aggressive price (in the figure, it is called middle price) to test the bottom line of the seller. The price algorithm is 2 × (recommend − offer). If the seller agrees to the price, user will be asked if he/she is satisfied with the transaction, and if they are satisfied, they will make a deal, but if they are not satisfied, they will make further bargaining. When the user is not satisfied with the transaction, Advisor Bot will give several options customers can negotiate according to their own needs, and Advisor Bot will tell customers two alternatives (Advisor Bot will combine the attributes input by user with the priorities of attributes and search similar commodities in other used car transaction platform). Alternatives serve as a reference helping user to determine whether they should agree to the deal. If the seller does not agree to aggressive price, the Advisor Bot will remind the user of asking the lowest price that the seller can offer. If the seller can give it, he will ask the user if he is satisfied, and the transaction will deal if he/she is satisfied. If he/she is not satisfied, he will be given options. The rest process is the same as the left sub tree in the decision tree as shown in Figure 2.

Judge Bot
Judge Bot's function is to grade user based on the result after negotiating. Judge Bot sets weights on those negotiable attributes and gives an overall score based on the combination of each score. This comprehensive score will be notified to the customer after each negotiation, print out each section's score, give the BATNA (Best Alternative) score and these things will be displayed in the scoring interface ( Figure 3). If the user is not satisfied, he/she can choose "no" and go back to the negotiation page ( Figure 4). The negotiation page will show all his/her alternatives. User can negotiate until he/she is satisfied, and the final decision depends on user. As shown in Figure 5, the best deal is 100 points meaning that all of the scoring detail is 100 (pay the car below the fair market price, get the best insurance and other attributes are the best).

Error Comparison
In order to evaluate our model, we use Quadratic Loss Function [14] to calculate the error of the algorithm in Price Bot. The data is shown below (Table 1). To better view the result, we also make a histogram ( Figure 6).
We run the algorithm ten times and get the average, variance, range and median. We can make several conclusions from Figure 6: 1) The performance of the     Figure 6. Error comparison.
Artificial Neural Network algorithm is the best compared with other algorithms and the 5-NN algorithm is the second; 2) The average, variance, range and median of SVR are very large, which means that the error rate fluctuates greatly and is very high when using this method, so its prediction of price is not accurate, probably may misleading the users.

Accuracy Comparison
For practical use, we defined a variable called Accuracy and a fluctuation region.
For example, when the fluctuation 10% deviated from real price, if 0.9 × real price < predict < 1.1 × real price, then Accuracy count will plus 1, Accuracy = (Accuracy Count)/(Size of test set) × 100. The data ( Table 2) are shown below, as well as the histogram (Figure 7). From Figure 7, the conclusion is almost the same as which is shown in the error comparison graph where the stability and precision of ANN is the best and SVR is the worst, but, in this case, NN is a little better than 5-NN.

Time Cost
The Time Cost Table (Table 3)  In summary, we chose NN algorithm as Machine Learning algorithm in our Price Bot. The reason why we did not choose the ANN is that although the neural network has higher accuracy and lower error, we need to consider the real-time interaction of users. Thus, the computing time required by the ANN is unacceptable.

Limitations of the App
The shortcomings of the project are: 1) when there are a large number of discrete data, the prediction results will be inaccurate. For example, the brand of the car, we process it into one hot data. As many brands as there are, there will be as many 0 -1 characters. It can be imagined that when the number of brands is increasing, that is, the distribution is becoming sparser, and the predicted results will be greatly biased.

Conclusion
We have implemented a primary intelligence robot that combines negotiation and deep learning algorithms and gave its application scenario. In this scenario, this robot can help buyers negotiate. The data in the negotiation robot comes from the data of a used car trading platform gripped by Crawler. These data are processed to predict the fair market price of used cars and are used as part of the negotiation basis to assist buyers in making decisions. Our negotiation bot gives a fair market price based on the used car data provided by the customer, and provides relative suggestions to the negotiation novice according to the market price, and then scores the performance, successfully simulating the application of a negotiation assistant robot in the negotiation process. This project is a preliminary attempt to combine artificial intelligence with negotiation technology, and there are many areas for revision and improvement. In the future, if Siri-like AI can be chosen as Advisor Bot, the robot will be more humane and likely to get more user feedback, thus improving the quality and satisfaction of negotiations. Negotiations today are almost based on experience. Although there are courses available for people to learn negotiation skills, people may not be able to immediately find the breakthrough point when negotiating. As a result, we try to quantify the negotiation elements, analyzing and refining them as the basis of creating negotiation assistant robots. The second-hand car trade is just a scenario that we realize. This negotiation assistant can also be used on other occasions where there are negotiations, such as bargaining when going to market or applying for jobs, just collecting enough data to train the machine learning model.
In the future, we can also improve in the Advisor Bot part for adding artificial intelligence similar to Siri to talk to human so that our app can meet more diverse needs of users.