background preloader

Android_motiuon_sensing

Facebook Twitter

Machine Learning. Exercise 6: Naive Bayes In this exercise, you will use Naive Bayes to classify email messages into spam and nonspam groups.

Machine Learning

Your dataset is a preprocessed subset of the Ling-Spam Dataset, provided by Ion Androutsopoulos. It is based on 960 real email messages from a linguistics mailing list. There are two ways to complete this exercise. The first option is to use the Matlab/Octave-formatted features we have generated for you. The second option is to generate the features yourself from the emails and then implement Naive Bayes on top of those features. Data Description The dataset you will be working with is split into two subsets: a 700-email subset for training and a 260-email subset for testing. 1. 2. 3. As an example, here are some messages before and after preprocessing: Nonspam message "5-1361msg1" before preprocessing Nonspam message "5-1361msg1" after preprocessing For comparison, here is a preprocessed spam message.

Spam message "spmsgc19" after preprocessing Multinomial Naive Bayes. Accessing the Accelerometer. Accessing the Accelerometer What is this: Your will learn how to access the Accelerometer Currently the emulator does not support the emulation of an accelerometer (it just returns [0, 0, 0] what is a Free-Fall ).

Accessing the Accelerometer

But when the functionality is available I will build a Class, where you can register, for special events, like, when the device is being shaken or similar. Problems/Questions: post right below... Difficulty: 2 of 5 Description: The accelerometer values indicate the acceleration in units of 1 = 1g = 9.8 m/s[sup]2[/sup] along the X, Y, and Z axes. Acceleration is defined such that a device in free fall has an accleration value of (0, 0, 0). 0.) Using java Syntax Highlighting import android.hardware.Sensors;public class AccelerometerReader { /** True when the Accelerometer-functionality is basically available. */ boolean accelerometerAvailable = false; boolean isEnabled = false;

Android: Collecting and Plotting Accelerometer Data. Today we’ll create an app to collect accelerometer reading and plot data in a XY-Line chart.

Android: Collecting and Plotting Accelerometer Data

Recipe Using the accelerometer to detect shaking of the device (Recipe 529, Revision 2821) Let us first define shaking as a fairly rapid movement of the device in one direction followed by further one in another direction, mostly but not necessarily the opposite.

Recipe Using the accelerometer to detect shaking of the device (Recipe 529, Revision 2821)

If we want to detect such a shake motion in an activity, we need a connection to the hardware sensors, those are exposed by the class SensorManager. Furthermore we need to define a SensorEventListener and register it with the SensorManager. So the source of our activity starts like this: public class ShakeActivity extends Activity { /* The connection to the hardware */ private SensorManager mySensorManager; /* The SensorEventListener lets us wire up to the real hardware events */ private final SensorEventListener mySensorEventListener = new SensorEventListener() { public void onSensorChanged(SensorEvent se) { /* we will fill this one later */ } public void onAccuracyChanged(Sensor sensor, int accuracy) { /* can be ignored in this example */ } }; .... Now let us define what we want to do when new sensor date arrives. Android Programming Tutorials. This example of using the accelerometer is designed to integrate the device’s acceleration to a position using the Verlet method.

Android Programming Tutorials

This is illustrated with a very simple particle system comprised of a few iron balls freely moving on an inclined wooden table. Algorithm: 1.) Create a new project by File-> New -> Android Project name it AccelerometerExample. 2.) Paste some images in your res/drawable-hdpi folder and name them ball.png and wood.png. 3.) Tutorial #1: Android Accelerometer Demo.

Motion Sensors. The Android platform provides several sensors that let you monitor the motion of a device.

Motion Sensors

Two of these sensors are always hardware-based (the accelerometer and gyroscope), and three of these sensors can be either hardware-based or software-based (the gravity, linear acceleration, and rotation vector sensors). For example, on some devices the software-based sensors derive their data from the accelerometer and magnetometer, but on other devices they may also use the gyroscope to derive their data.

Most Android-powered devices have an accelerometer, and many now include a gyroscope. The availability of the software-based sensors is more variable because they often rely on one or more hardware sensors to derive their data. Motion sensors are useful for monitoring device movement, such as tilt, shake, rotation, or swing. All of the motion sensors return multi-dimensional arrays of sensor values for each SensorEvent. Table 1. Android Sensor.

Android Sensor - Tutorial Copyright © 2011, 2012 Lars Vogel Android Sensor This tutorial describes how to use the Androids Sensor manager.

Android Sensor

The tutorial is based on Eclipse 3.6, Java 1.6 and Android 2.3.3 (Gingerbread). Android SDK Tutorial: Accelerometer Example Code. This is am going to teach to make is so simple but I could be playing with it for hours, just think of all the possibilities.

Android SDK Tutorial: Accelerometer Example Code

The Result We will make a simple app, one that shows you the acceleration of your phone/tablet in all axes. The acceleration won’t be zero when your are not moving though but the numbers for each axis will change when you tilt your device in any direction. Android app showing accelration in the x y and z axes. Sensor - How to detect movement of an android device.