Linear Algebra in Python Scripts

Preparing data for tensorflow is often easiest when done as a two step process. In machine learning, you often get into trying to plot points, calculate tangents, and a lot of basic algebra. Working out equations kinda’ reminds me of being in in-school suspension in high school. Except now we’re writing code to solve the problems rather than solving them ourselves.

I never liked solving for a matrix… But NumPy is a great little framework to import that does a lot of N-dimensional array work. A few basic tasks in the following script includes a number of functions across norms, matrix products, vector products, decompose, and eigenvalues. Remove/comment what you don’t need:

import numpy as np from numpy import linalg as LA array = [[-1,4,2],[1,-1,3]] array2 = [[6,2,1],[7,1,-3]] array = np.asarray(array) converted = np.fliplr(array) #ifsquare >> cholesky = LA.cholesky(array) #ifsquare >> inv = LA.inv(array) #ifsquare >> determinant = LA.det(array) #ifsquare >> signlog = LA.slogdet(array) print print 'ONE ARRAY' print 'Sum: ', np.trace(converted) print 'Elements: ', np.diagonal(converted) print 'Solved: ', LA.norm(array) print 'qr factorization: ' print np.linalg.qr(array) print 'Hermitian: ' print LA.svd(array) print print 'TWO ARRAYS' print 'vdot: ',np.vdot(array,array2) print 'Inner: ' print np.inner(array,array2) print 'Outer: ' print np.outer(array,array2) print 'Tensor dot product: ',np.tensordot(array,array2) print 'Kronecker product: ' print np.kron(array,array2)

10 Laws of Support Chatbots


I really enjoy chatbots. They can be way more pleasant to work with than some some service desks out there who are after cheaper rather than better support options for customers. And rarely do we see a service desk that isn’t growing at a slower rate than customer growth, so in most cases they’re fast to get to and easier to train that actual humanness. But some chatbots are amazing and others can be terrible.

So let’s look at Asimov’s, er I mean, my laws of chatbots:

  1. Chatbots should be connected to an extensive list of content to analyze and make recommendations so they can meaningfully answer questions.
  2. Chatbots should allow visitors to type in real questions rather than choose prompts as is typical with automated call distribution and routing systems we’re used to.
  3. The location the chatbot is being opened from on our website should usually be able to replace legacy call routing information or at a minimum provide useful metadata to any machine learning algorithms used to direct users to content.
  4. If a chatbot is taking an action (e.g. dispatch an engineer to fix the HVAC system) then a human should probably accept the request, even if that human is the person on the other end of a chatbot who initiated the request.
  5. Chatbots should always be courteous. If the chatbot doesn’t say please and thank you then your chatbot is not courteous and is at best probably a glorified search page. 
  6. Much as a chatbot should be courteous, it should also track instances of abuse. It’s also OK to tell visitors that the chatbot is being trained. Because if it’s good it’s always being trained. 
  7. After no more than three incorrect attempts to answer a question the chatbot should offer to connect the session to a human
  8. A human should always be one button click away.
  9. Chatbots should have Easter Eggs. Why? Because Easter Eggs are awesome.
  10. Much as you should never turn a bag of holding inside out, chatbots should never talk to one another. If they do just call them API automations and get it over with…