Contents tagged with Python

  • Built in data sets in Sklearn and visualization with Pandas

    Hello everybody,

    today I want to write a few words about built in data sets in sklearn library of python but from Visual Studio 2017 prospective. You may ask why Visual Studio 2017 if there are plenty of other options? I can say that main reason is becuase I like debugging features that availabile in Visual Studio which make my life much simpler. 

    Initial headers and one function

    So, before we continue, we need as usually in Pythong import some basic libraries. You can do it in Visual studio like this:

    import sklearn

    from matplotlib import pylab

    import matplotlib

    import matplotlib.pyplot as pyplot

    import numpy as np

    from sklearn import datasets

    def sanitize_sequence(data): … more

  • Functions map, zip and lambda in Python

    Hello everybody,

    today I want to describe three elements of Python: map, zip, lambda and *.

    Zip and *

    The first step that I want to describe is zip and * usage. Take a look at the following code:

    a = [5, 6]

    b = [7, 8]

    c = zip(a,b)

    print(*c)

    How do you think, what will be output, if I'll tell you that zip function zips arrays? If your guess is (5, 6) (7, 8) then unfortunately you are wrong. Output will be the following:

    (5, 7) (6, 8). I suppose that zip name was chosen because as usually zippers on clothes as usually vertical. Zip functions "zips" elements by columns, like presented on the picture:

    Now one more question, what is purpose of * ? It tells to Python interpreter to … more

  • How to read little endian file of floats in Java

    Hello everybody,

    today I want to document another issue that took from me plenty of time. Recently I've used following code in Python in order to save array of numpy numbers:

    import numpy as np

    newImage = ...some way of getting array

    np.ndarray.tofile(newImage, newFn)

    But when I tried to get that content in Java code, I faced issue that my inputs where unreadable by Java. After spending some time over net I've found that Python uses little endian encoding, while Java uses another encoding for saving floats. 

    So my research of little endian gave me the following code result in java for reading little endian:

    InputStream inputStream = null;DataInputStream dataInputStream = null; … more