Artificial Intelligence By Example
上QQ阅读APP看书,第一时间看更新

Using supervised learning to evaluate result quality

Having now obtained the npv, a more business-like measurement must be implemented.

A warehouse manager, for example, will tell you the following:

  • Your reinforcement learning program looks satisfactory (Chapter 1, Become an Adaptive Thinker)
  • The reward matrix generated by the McCulloch-Pitts neurons works very well (Chapter 2, Think Like a Machine)
  • The convergence values of the system look nice
  • The results on this dataset look satisfactory

But then, the manager will always come up with a killer question, How can you prove that this will work with other datasets in the future?

The only way to be sure that this whole system works is to run thousands of datasets with hundreds of thousands of product flows.

The idea now is to use supervised learning to create relationships between the input and output data. It's not a random process like MDP. They are not trajectories anymore. They are priorities. One method is to used decision trees. In Chapter 4Become an Unconventional Innovator, the problem will be solved with a feedforward backpropagation network.

In this model, the properties of the customer orders are analyzed so that we can classify them. This can be translated into decision trees depending on real-time data, to create a distribution representation to predict future outcomes.

  1. The first step is to represent the properties of the orders O1 to O6.
features = [ 'Priority/location', 'Volume', 'Flow_optimizer' ]

In this case, we will limit the model to three properties:

    • Priority/location, which is the most important property in a warehouse flow in this model
    • Volumes to transport
    • Optimizing priority—the financial and customer satisfaction property
  1. The second step is to provide some priority parameters to the learning dataset:
Y = ['Low', 'Low', 'High', 'High', 'Low', 'Low
  1. Step 3 is providing the dataset input matrix, which is the output matrix of the reinforcement learning program. The values have been approximated but are enough to run the model. This simulates some of the intermediate decisions and transformations that occur during the decision process (ratios applied, uncertainty factors added, and other parameters). The input matrix is X:
X = [ [256, 1,0], 
[320, 1,0],
[500, 1,1],
[400, 1,1],
[320, 1,0],
[256, 1,0]]

The features in step 1 apply to each column.

The values in step 2 apply to every line.

  1. Step 4 is running a standard decision tree classifier. This classifier will distribute the representations (distributed representations) into two categories:
    • The properties of high-priority orders
    • The properties of low-priority orders

There are many types of algorithms. In this case, a standard sklearn function is called to do the job, as shown in the following source code.

classify = tree.DecisionTreeClassifier()
classify = classify.fit(X,Y)

Applied to thousands of orders on a given day, it will help adapt to real-time unplanned events that destabilize all scheduling systems: late trucks, bad quality products, robot breakdowns, and absent personnel. This means that the system must be able to constantly adapt to new situations and provide priorities to replan in real time. 

The program will produce the following graph, which separates the orders into priority groups.

The goal now is to separate the best orders to replan among hundreds of thousands of simulating orders. In this case, the learning dataset has the six values you have been studying in the first two chapters from various angles.

  • Priority/location<=360.0 is the pision point between the most probable optimized orders (high) and less interesting ones (low).
  • Gini impurity. This would be the measure of incorrect labeling if the choice were random. In this case, the dataset is stable.
  • The false arrow points out the two values that are not <=360, meaning they are good choices, the optimal separation line of the representation. The ones that are not classified as False are considered as don't eliminate orders.
    The True elements mean: eliminate orders as long as possible.
  • The value result reads as [number of false elements, number of true elements] of the dataset.

If you play around with the values in steps 1, 2, and 3, you'll obtain different separation points and values. This sandbox program will prepare you for the more complex scheduling problems of Chapter 12, Automated Planning and Scheduling.

You can use this part of the source code to generate images of this decision tree-supervised learning program:

# 5.Producing visualization if necessary
info = tree.export_graphviz(classify,feature_names=features,out_file=None,filled=False,rounded=False)
graph = pydotplus.graph_from_dot_data(info)

edges = collections.defaultdict(list)
for edge in graph.get_edge_list():
edges[edge.get_source()].append(int(edge.get_destination()))

for edge in edges:
edges[edge].sort()
for i in range(2):
dest = graph.get_node(str(edges[edge][i]))[0]

graph.write_png('warehouse_example_decision_tree.png')
print("Open the image to verify that the priority level prediction of the results fits the reality of the reward matrix inputs")

The preceding information represents a small part of what it takes to manage a real-life artificial intelligence program on premise.

A warehouse manager will want to run this supervised learning decision tree program on top of the system described in Chapter 2, Think Like a Machine, and Chapter 3Apply Machine Thinking to a Human Problem. This is done to generalize these distributed representations directly to the warehouse data to improve the initial corporate data inputs. With better-proven priorities, the system will constantly improve, week by week.

This way of scheduling shows that human thinking was not used nor necessary.

Contrary to the hype surrounding artificial intelligence, most problems can be solved with no human intelligence involved and relatively little machine learning technology.

Human intelligence simply proves that intelligence can solve a problem.

Fortunately for the community of artificial intelligence experts, there are very difficult problems to solve that require more artificial intelligence thinking.

Such a problem will be presented and solved in Chapter 4, Become an Unconventional Innovator.

The Python  program is available at https://github.com/PacktPublishing/Artificial-Intelligence-By-Example/blob/master/Chapter03/Decision_Tree_Priority_classifier.py.