Outside the Python ecosystem, programming languages such as R, C, Java, and Fortran are fairly popular. In this chapter, we will delve into the particulars of exchanging information with these environments.
Cloud computing aims to deliver computing power as a utility over the Internet. This means that we don't need to have a lot of powerful hardware locally. Instead, we pay as we go—depending on our current needs. We will also talk about how to get our Python code in the Cloud. This is a rapidly evolving industry in a fast-paced world. We have many options available, of which we will cover Google App Engine and PythonAnywhere. Amazon Web Services (AWS) is deliberately not discussed in this book, since other books such as Building Machine Learning Systems with Python, Willi Richert and Luis Pedro Coelho, Packt Publishing, mentioned in the Preface, cover the topic in great detail. We should also be aware of the Data Science Toolbox at http://datasciencetoolbox.org/. This is a virtual environment for data analysis based on Linux, which can be run locally or on AWS. The instructions given on the Data Science Toolbox website are very clear and should help you set up an environment with lots of Python packages that we have already installed.
The topics that will be covered in this chapter are as follows:
MATLAB and its open source alternative Octave are popular numerical programs and programming languages. Octave and MATLAB have syntax very similar to Python's. In fact, you can find websites that compare their syntax (for instance, see http://wiki.scipy.org/NumPy_for_Matlab_Users).
Download Octave from http://www.gnu.org/software/octave/download.html.
The most recent Octave version at the time of writing was 3.8.0. The scipy.io.savemat()
function saves an array in a file compliant to the Octave and MATLAB format. The function accepts as parameters the name of the file and a dictionary with a name for the array and the values. Refer to the octave_demo.py
file in this book's code bundle:
import statsmodels.api as sm from scipy.io import savemat data_loader = sm.datasets.sunspots.load_pandas() df = data_loader.data savemat("sunspots", {"sunspots": df.values})
The preceding code stores sunspots data in a file called sunspots.mat
. The extension is added automatically. Start the Octave Graphical User Interface or command-line interface. Load the file we created and view the data as follows:
octave:1> load sunspots.mat octave:2> sunspots sunspots = 1.7000e+03 5.0000e+00 1.7010e+03 1.1000e+01 1.7020e+03 1.6000e+01 …
18.191.205.99