Direkt zum Hauptbereich

Posts

Posts mit dem Label "Python" werden angezeigt.

What's wrong with Scala? About Yate's Correction

Some months ago, I started a new job as a machine learning engineer for a german trading company. In the course of this, I began to deal more with the programming language Scala. Scala provides some benefits that makes the work easier for data engineers when building data pipelines and there's a good support for spark, which is an advantage in cluster computing. But Scala (of course) also has its idiosyncrasies. This article shows the idiosyncrasy of Yate's correction in the Statistcs package of Scala and its consequences. The Statistics Package Like many other programming languages, Scala also comes with a statistical package called "Statistics". It includes many basic methods of the describing statistics, which you need for many purposes. One of these purposes is, for example, A/B testing. So, what's wrong with Scala? For an A/B test, I tested the significance by own calculations first (in old manner, as I had learned in my studies) before using th...

Pi And More 11 - Python Blinker Class

This source code is part of the Python magnetic field sensor and detector project . This class only provides a simple flashing indicator light for the project. ######################################## # # Python Magnetic Field Logger and Detector # by Sebastian Folz # Introduced on Pi And More 11 # ######################################## # Don't use time module, because there is no valid time without WiFi import time import sqlite3 as lite from qmc5883 import QMC5883 import statistics # import functions for system calls from subprocess import call import sys # import pushbutton class from pushbutton import pushbutton, Push # import blink class from Blinker import Blink1, Blink2 from enum import Enum import RPi.GPIO as GPIO # fix copy bug with switched arguments from shutil import copyfile # Import own neural net class from MLP import MLNN TASTER = 38 LED = 40 LONG_CYCLES = 10 # 1.5 seconds COMMIT = 10 BINSIZE = 10 #...

Pi And More 11 - Python Pushbutton Class

As on PAM 11 in Trier introduced: Python-Logger-Class (Push Button Library) as part of the Python magnetic field logger and detector project . ######################################## # # Python Magnetic Field Logger and Detector # by Sebastian Folz # Pusbutton library - handles push buttons # Introduced on Pi And More 11 # ######################################## # import GPIO import RPi.GPIO as GPIO # enumerations from enum import Enum class Push (Enum): NONE = 0 SHORT_DOWN = 1 LONG_DOWN = 2 class pushbutton : #pushed = False def __init__ ( self ): GPIO . setmode(GPIO . BOARD) self . pushed = False self . pin = - 1 self . cycles = 0 def setLongCycle ( self , cycles): self . long_cycles = cycles; def configure ( self , aPin): self . pin = aPin GPIO . setup( self . pin, GPIO . IN, pull_up_down = GPIO . PUD_UP) def isPushed ( self ): # ...

Pi And More 11 - Python Magnetic Field Logger And Detector

As introduces atn PAM 11 in Trier: The Python-Logger-Class. This is the main class for my Raspberry Pi 3 machine learning experiment. Please consider, that three more classes are required: The QMC5883 driver class , the pushbutton class and the blinker class . Furthermore, the R script for the training of the neuronal net is required. ######################################## # # Python Magnetic Field Logger and Detector # by Sebastian Folz # Introduced on Pi And More 11 # ######################################## # Don't use time module, because there is no valid time without WiFi import time import sqlite3 as lite from qmc5883 import QMC5883 import statistics # import functions for system calls from subprocess import call import sys # import pushbutton class from pushbutton import pushbutton, Push # import blink class from Blinker import Blink1, Blink2 from enum import Enum import RPi.GPIO as GPIO # fix copy bug with switched argume...

Pi And More 11 - QMC5883 Magnetic Field Sensor Class

A little aside from the analytical topics of this blog, I also was occupied with a little ubiquitous computing project. It was about machine learning with a magnetic field sensor, the QMC5883. In the Arduino module GY-271, usually the chip HMC5883 is equipped. Unfortunately, in cheap modules from china, another chip is used: the QMC5883. And, as a matter of course, the software library used for the HMC5883 does not work with the QMC version, because the I2C adress and the usage is a little bit different. Another problem to me was, that I  didn't find any proper working source codes for that little magnetic field device, and so I had to debug a source code I found for Arduino at Github  (thanks to dthain ). Unfortunately it didn't work properly at this time, and to change it for the Raspberry Pi into Python. Below you can find the "driver" module for the GY-271 with the QMC5883 chip. Sorry for the bad documentation, but at least it will work on a Raspberry Pi 3. ...