O'Reilly logo

Effective Amazon Machine Learning by Alexis Perrier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Driving the trials in Python

So far, we have written sequential code in Python. Writing simple object-oriented code instead is always a time saver in the end. The code is more organized, maintainable, and less prone to becoming unusable after a while. Taking the time to write simple classes with clear initialization, instances and class methods will make your code much simpler and robust in the end. With that in mind, we will now write a NonLinear class for our experiment. 

Let's first write down the different functions of that class that generate some of the fields that depend on the power of the polynomial regression:

  • This function takes in a power p and returns the SQL query:
      def generate_sql(self, p): powers = [ 'power(x,{0}) as x{0}'.format(i) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required