Uses WiFi signals :signal_strength: and machine learning to predict where you are

Overview

whereami

Build Status Coverage Status PyPI PyPI

Uses WiFi signals and machine learning (sklearn's RandomForest) to predict where you are. Even works for small distances like 2-10 meters.

Your computer will known whether you are on Couch #1 or Couch #2.

Cross-platform

Works on OSX, Windows, Linux (tested on Ubuntu/Arch Linux).

The package access_points was created in the process to allow scanning wifi in a cross platform manner. Using access_points at command-line will allow you to scan wifi yourself and get JSON output. whereami builds on top of it.

Installation

pip install whereami

Usage

# in your bedroom, takes a sample
whereami learn -l bedroom

# in your kitchen, takes a sample
whereami learn -l kitchen

# get a list of already learned locations
whereami locations

# cross-validated accuracy on historic data
whereami crossval
# 0.99319

# use in other applications, e.g. by piping the most likely answer:
whereami predict | say
# Computer Voice says: "bedroom"

# probabilities per class
whereami predict_proba
# {"bedroom": 0.99, "kitchen": 0.01}

If you want to delete some of the last lines, or the data in general, visit your $USER/.whereami folder.

Python

Any of the functionality is available in python as well. Generally speaking, commands can be imported:

from whereami import learn
from whereami import get_pipeline
from whereami import predict, predict_proba, crossval, locations

Accuracy

k Generally it should work really well. I've been able to learn using only 7 access points at home (test using access_points -n). At organizations you might see 70+.

Distance: anything around ~10 meters or more should get >99% accuracy.

If you're adventurous and you want to learn to distinguish between couch #1 and couch #2 (i.e. 2 meters apart), it is the most robust when you switch locations and train in turn. E.g. first in Spot A, then in Spot B then start again with A. Doing this in spot A, then spot B and then immediately using "predict" will yield spot B as an answer usually. No worries, the effect of this temporal overfitting disappears over time. And, in fact, this is only a real concern for the very short distances. Just take a sample after some time in both locations and it should become very robust.

Height: Surprisingly, vertical difference in location is typically even more distinct than horizontal differences.

Related Projects

  • The wherearehue project can be used to toggle Hue light bulbs based on the learned locations.

Almost entirely "copied" from:

https://github.com/schollz/find

That project used to be in Python, but is now written in Go. whereami is in Python with lessons learned implemented.

Tests

It's possible to locally run tests for python 2.7, 3.4 and 3.5 using tox.

git clone https://github.com/kootenpv/whereami
cd whereami
python setup.py install
tox
Comments
  • Windows 10: ValueError: Found array with 0 feature(s) (shape=(100, 0)) while a minimum of 1 is required.

    Windows 10: ValueError: Found array with 0 feature(s) (shape=(100, 0)) while a minimum of 1 is required.

    I'm using miniconda.

    (py2) C:\Users\jane_>python --version
    Python 2.7.12 :: Continuum Analytics, Inc.
    
    (py2) C:\Users\jane_>conda list
    # packages in environment at C:\Users\jane_\Miniconda3\envs\py2:
    #
    access-points             0.0.18                    <pip>
    mkl                       11.3.3                        1
    numpy                     1.11.1                   py27_1
    pip                       8.1.2                    py27_0
    python                    2.7.12                        0
    scikit-learn              0.17.1              np111py27_1
    scipy                     0.18.1              np111py27_0
    setuptools                27.2.0                   py27_1
    tqdm                      4.8.4                     <pip>
    vs2008_runtime            9.00.30729.1                  2
    wheel                     0.29.0                   py27_0
    whereami                  0.2.29                    <pip>
    
    (py2) C:\Users\jane_>whereami learn -l bookshelf -n 100
    100%|################################################################################| 100/100 [00:14<00:00,  6.79it/s]
    Traceback (most recent call last):
      File "c:\users\jane_\miniconda3\envs\py2\lib\runpy.py", line 174, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "c:\users\jane_\miniconda3\envs\py2\lib\runpy.py", line 72, in _run_code
        exec code in run_globals
      File "C:\Users\jane_\Miniconda3\envs\py2\Scripts\whereami.exe\__main__.py", line 9, in <module>
      File "c:\users\jane_\miniconda3\envs\py2\lib\site-packages\whereami\__main__.py", line 34, in main
        learn(args.location, args.num_samples)
      File "c:\users\jane_\miniconda3\envs\py2\lib\site-packages\whereami\learn.py", line 25, in learn
        train_model()
      File "c:\users\jane_\miniconda3\envs\py2\lib\site-packages\whereami\pipeline.py", line 33, in train_model
        lp.fit(X, y)
      File "c:\users\jane_\miniconda3\envs\py2\lib\site-packages\sklearn\pipeline.py", line 165, in fit
        self.steps[-1][-1].fit(Xt, y, **fit_params)
      File "c:\users\jane_\miniconda3\envs\py2\lib\site-packages\sklearn\ensemble\forest.py", line 212, in fit
        X = check_array(X, dtype=DTYPE, accept_sparse="csc")
      File "c:\users\jane_\miniconda3\envs\py2\lib\site-packages\sklearn\utils\validation.py", line 415, in check_array
        context))
    ValueError: Found array with 0 feature(s) (shape=(100, 0)) while a minimum of 1 is required.
    
    opened by balta2ar 18
  • Integer parsing error upon First Sampling

    Integer parsing error upon First Sampling

    Hi, I just tried to run whereami for the first time, and I got the following strange error:

    peachg@deino ~/P/blog_os> whereami learn -l my_room
      2%|▊                                          | 2/100 [00:07<06:15,  3.83s/it]
    Traceback (most recent call last):
      File "/usr/local/bin/whereami", line 11, in <module>
        sys.exit(main())
      File "/usr/local/lib/python2.7/site-packages/whereami/__main__.py", line 34, in main
        learn(args.location, args.num_samples)
      File "/usr/local/lib/python2.7/site-packages/whereami/learn.py", line 22, in learn
        write_data(label_path, sample())
      File "/usr/local/lib/python2.7/site-packages/whereami/get_data.py", line 14, in sample
        aps = wifi_scanner.get_access_points()
      File "/usr/local/lib/python2.7/site-packages/access_points/__init__.py", line 33, in get_access_points
        results = self.parse_output(out)
      File "/usr/local/lib/python2.7/site-packages/access_points/__init__.py", line 62, in parse_output
        ap = AccessPoint(ssid, bssid, rssi_to_quality(int(rssi)), security)
    ValueError: invalid literal for int() with base 10: ''
    

    Python 2.7, OSX 10.11.6.

    opened by Others 13
  • Added external data support

    Added external data support

    I added in the ability to specify paths to both the model/trained data, and a path to find the current activity, or current X which we are trying to fit.

    If a path is not specified, the normal flows continue.

    opened by AndrewDessin 4
  • ValueError: Sample sequence X is empty

    ValueError: Sample sequence X is empty

    I'm tried to run whereami learn -l test_location -n 100 and get following error:

    ➜  test git:(master) ✗ whereami learn -l test_location -n 100
    100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 53.30it/s]
    Traceback (most recent call last):
      File "/usr/local/bin/whereami", line 11, in <module>
        sys.exit(main())
      File "/usr/local/lib/python3.5/site-packages/whereami/__main__.py", line 39, in main
        learn(args.location, args.num_samples)
      File "/usr/local/lib/python3.5/site-packages/whereami/learn.py", line 27, in learn
        train_model()
      File "/usr/local/lib/python3.5/site-packages/whereami/pipeline.py", line 27, in train_model
        lp.fit(X, y)
      File "/usr/local/lib/python3.5/site-packages/sklearn/pipeline.py", line 268, in fit
        Xt, fit_params = self._fit(X, y, **fit_params)
      File "/usr/local/lib/python3.5/site-packages/sklearn/pipeline.py", line 234, in _fit
        Xt = transform.fit_transform(Xt, y, **fit_params_steps[name])
      File "/usr/local/lib/python3.5/site-packages/sklearn/feature_extraction/dict_vectorizer.py", line 231, in fit_transform
        return self._transform(X, fitting=True)
      File "/usr/local/lib/python3.5/site-packages/sklearn/feature_extraction/dict_vectorizer.py", line 184, in _transform
        raise ValueError("Sample sequence X is empty.")
    ValueError: Sample sequence X is empty.
    

    OS version: macOS 10.12.1 Python version: 3.5.2

    opened by drakmail 4
  • Access Point: ValueError: not enough values to unpack (expected 4, got 1)

    Access Point: ValueError: not enough values to unpack (expected 4, got 1)

    Hello, kootenpv. First of all, creating thanks for the project!

    Kootenpv, every time I try to learn (e.g. whereami learn -l bedroom) I get the following error:

    0%| | 0/100 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/lucas/anaconda3/bin/whereami", line 11, in sys.exit(main()) File "/home/lucas/anaconda3/lib/python3.5/site-packages/whereami/main.py", line 39, in main learn(args.location, args.num_samples) File "/home/lucas/anaconda3/lib/python3.5/site-packages/whereami/learn.py", line 22, in learn new_sample = sample() File "/home/lucas/anaconda3/lib/python3.5/site-packages/whereami/get_data.py", line 15, in sample aps = wifi_scanner.get_access_points() File "/home/lucas/anaconda3/lib/python3.5/site-packages/access_points/init.py", line 77, in get_access_points results = self.parse_output(out) File "/home/lucas/anaconda3/lib/python3.5/site-packages/access_points/init.py", line 210, in parse_output ssid, bssid, quality, security = split_escaped(line, ':') ValueError: not enough values to unpack (expected 4, got 1)

    I imported the project into PyCharm and all the tests were run successfuly. That seems weird.

    Can we fix this?

    opened by lucasmauro 4
  • Issue with

    Issue with "whereami predict | say"

    When I run, "whereami predict_proba" I get a value of 1.0 for my location. But when I do "whereami predict | say" it does nothing.

    opened by wdibi 4
  • Unrecognized Arguments -n

    Unrecognized Arguments -n

    Hey there,

    I was trying to use 'whereami'. I use python 2.7, and installed whereami by pip. I get the following error message.

    >>> whereami learn -l work2 -n 100
    usage: whereami [-h] [--version]
                    {predict,predict_proba,crossval,locations,ls,learn,rename} ...
    whereami: error: unrecognized arguments: -n 100
    

    Best Stefan

    opened by stefanhuber1993 3
  • Ubuntu:ValueError: need more than 1 value to unpack

    Ubuntu:ValueError: need more than 1 value to unpack

    Hi,

    Newbie here, I run the command "whereami learn -l bedroom -n 100" at first time, it got error as below:

    0%| | 0/100 [00:00<?, ?it/s] Traceback (most recent call last): File "/usr/local/bin/whereami", line 9, in load_entry_point('whereami==0.3.50', 'console_scripts', 'whereami')() File "/usr/local/lib/python2.7/dist-packages/whereami-0.3.50-py2.7.egg/whereami/main.py", line 39, in main learn(args.location, args.num_samples) File "/usr/local/lib/python2.7/dist-packages/whereami-0.3.50-py2.7.egg/whereami/learn.py", line 22, in learn new_sample = sample() File "/usr/local/lib/python2.7/dist-packages/whereami-0.3.50-py2.7.egg/whereami/get_data.py", line 15, in sample aps = wifi_scanner.get_access_points() File "/usr/local/lib/python2.7/dist-packages/access_points/init.py", line 77, in get_access_points results = self.parse_output(out) File "/usr/local/lib/python2.7/dist-packages/access_points/init.py", line 210, in parse_output ssid, bssid, quality, security = split_escaped(line, ':') ValueError: need more than 1 value to unpack

    What kind of additional argument I should put in the command?

    Thanks

    opened by MaDragon 3
  • OSX error

    OSX error

    "This module will be removed in 0.20.", DeprecationWarning)
     21%|████████▊                                 | 21/100 [00:32<02:03,  1.57s/it]
    Traceback (most recent call last):
      File "/usr/local/bin/whereami", line 11, in <module>
        sys.exit(main())
      File "/Library/Python/2.7/site-packages/whereami/__main__.py", line 34, in main
        learn(args.location, args.num_samples)
      File "/Library/Python/2.7/site-packages/whereami/learn.py", line 22, in learn
        write_data(label_path, sample())
      File "/Library/Python/2.7/site-packages/whereami/get_data.py", line 14, in sample
        aps = wifi_scanner.get_access_points()
      File "/Library/Python/2.7/site-packages/access_points/__init__.py", line 34, in get_access_points
        results = self.parse_output(out)
      File "/Library/Python/2.7/site-packages/access_points/__init__.py", line 60, in parse_output
        for network in read_plist(output):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 103, in readPlistFromString
        return readPlist(StringIO(data))
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
        rootObject = p.parse(pathOrFile)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
        parser.ParseFile(fileobj)
    xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1038, column 10
    
    
    opened by suhaotian 3
  • (Py3) bad command line in examples

    (Py3) bad command line in examples

    Just installed (few minutes after #3).

    (py3) ❯ whereami learn bed 100
    usage: whereami learn [-h] --location LOCATION [--num_samples NUM_SAMPLES]
    whereami learn: error: the following arguments are required: --location/-l
    
    
    
    (py3) ❯ whereami learn --location bed --num_samples 100
    [this works]
    
    
    
    (py3) ❯ pip freeze
    access-points==0.0.11
    numpy==1.11.1
    scikit-learn==0.17.1
    scipy==0.18.1
    tqdm==4.8.4
    whereami==0.2.21
    
    opened by kgadek 3
  • (Python 2.7) predict_proba throws AttributeError

    (Python 2.7) predict_proba throws AttributeError

    Running OS X El Capitan (10.11.6), Python 2.7.11, whereami 0.1.17

    predict works properly, but predict_proba makes the calculations (which I can tell because it takes a few seconds) and then throws an AttributeError.

    Rogers-MacBook-Air:~ roger$ whereami predict_proba
    Traceback (most recent call last):
      File "/Users/roger/anaconda/bin/whereami", line 11, in <module>
        sys.exit(main())
      File "/Users/roger/anaconda/lib/python2.7/site-packages/whereami/__main__.py", line 10, in main
        predict_proba()
      File "/Users/roger/anaconda/lib/python2.7/site-packages/whereami/predict.py", line 9, in predict_proba
        print({x: y for x, y in zip(lp.clf.classes_, lp.predict_proba(sample())[0])})
    AttributeError: 'Pipeline' object has no attribute 'clf'
    
    opened by rfilmyer 3
  • Please cooperate with the Openhab project to make binding.

    Please cooperate with the Openhab project to make binding.

    How to develop a "binding": https://www.openhab.org/docs/developer/bindings/

    What is OpenHab: https://www.openhab.org/

    A list of what kind of systems and things Openhab can communicate with: https://www.openhab.org/addons/

    Feature request: https://github.com/openhab/openhab-addons/issues/11209

    opened by Supermagnum 0
  • Installing whereami on MacBook with M1 Chip running Big Sur

    Installing whereami on MacBook with M1 Chip running Big Sur

    Hi, I'm hoping I can get some help with an installation issue. I have python3.8 and Whereami running perfectly on a Catalina device. I recently tried installing it on an M1 MacBook running Big Sur, but was unsuccessful. I have python3.9 installed on BigSur. When I run the command pip3 install whereami, it hangs at:

    ERROR: Failed building wheel for numpy Failed to build numpy ERROR: Could not build wheels for numpy which uses PEP 517 and cannot be installed directly

    If anyone has advice about how I can fix this problem, I would greatly appreciate it!

    opened by gseiki 2
  • Locations lose trailing 't' or 'x'

    Locations lose trailing 't' or 'x'

    The names of locations lose any number of trailing 't' or 'x' characters, e.g.

    $ whereami learn -l couch-right &>/dev/null
    $ whereami locations
    couch-righ: 1
    

    This is due to using rstrip(".txt") on the filename at get_data.py:42, which will strip any number of '.', 't', or 'x' characters.

    opened by iamthad 0
  • ValueError: n_splits=10 cannot be greater than the number of members in each class.

    ValueError: n_splits=10 cannot be greater than the number of members in each class.

    When running whereami crossval, I get

    ValueError: n_splits=10 cannot be greater than the number of members in each class.
    

    I suspect this happens when the total number of samples is >= 10, but one of the locations has < 10 samples. This case should be checked for and handled gracefully the same way as the case when the total number of samples is < 10, i.e. not throw an exception.

    opened by dkasak 0
  • Update dependencies

    Update dependencies

    On python3.3.6:

    /usr/local/lib64/python3.6/site-packages/sklearn/ensemble/weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.
      from numpy.core.umath_tests import inner1d
    
    opened by ktwzk 0
Owner
Pascal van Kooten
AI / Deep learning enthusiast
Pascal van Kooten
This machine-learning algorithm takes in data from the last 60 days and tries to predict tomorrow's price of any crypto you ask it.

Crypto-Currency-Predictor This machine-learning algorithm takes in data from the last 60 days and tries to predict tomorrow's price of any crypto you

Hazim Arafa 6 Dec 4, 2022
A Python Module That Uses ANN To Predict A Stocks Price And Also Provides Accurate Technical Analysis With Many High Potential Implementations!

Stox A Module to predict the "close price" for the next day and give "technical analysis". It uses a Neural Network and the LSTM algorithm to predict

Stox 31 Dec 16, 2022
Ml based project which uses regression technique to predict the price.

Price-Predictor Ml based project which uses regression technique to predict the price. I have used various regression models and finds the model with

Garvit Verma 1 Jul 9, 2022
Machine Learning Model to predict the payment date of an invoice when it gets created in the system.

Payment-Date-Prediction Machine Learning Model to predict the payment date of an invoice when it gets created in the system.

null 15 Sep 9, 2022
pure-predict: Machine learning prediction in pure Python

pure-predict speeds up and slims down machine learning prediction applications. It is a foundational tool for serverless inference or small batch prediction with popular machine learning frameworks like scikit-learn and fasttext. It implements the predict methods of these frameworks in pure Python.

Ibotta 84 Dec 29, 2022
We have a dataset of user performances. The project is to develop a machine learning model that will predict the salaries of baseball players.

Salary-Prediction-with-Machine-Learning 1. Business Problem Can a machine learning project be implemented to estimate the salaries of baseball players

Ayşe Nur Türkaslan 9 Oct 14, 2022
A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.

Master status: Development status: Package information: TPOT stands for Tree-based Pipeline Optimization Tool. Consider TPOT your Data Science Assista

Epistasis Lab at UPenn 8.9k Jan 9, 2023
Python Extreme Learning Machine (ELM) is a machine learning technique used for classification/regression tasks.

Python Extreme Learning Machine (ELM) Python Extreme Learning Machine (ELM) is a machine learning technique used for classification/regression tasks.

Augusto Almeida 84 Nov 25, 2022
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques

Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

Vowpal Wabbit 8.1k Dec 30, 2022
CD) in machine learning projectsImplementing continuous integration & delivery (CI/CD) in machine learning projects

CML with cloud compute This repository contains a sample project using CML with Terraform (via the cml-runner function) to launch an AWS EC2 instance

Iterative 19 Oct 3, 2022
Houseprices - Predict sales prices and practice feature engineering, RFs, and gradient boosting

House Prices - Advanced Regression Techniques Predicting House Prices with Machine Learning This project is build to enhance my knowledge about machin

null 1 Jan 1, 2022
Used Logistic Regression, Random Forest, and XGBoost to predict the outcome of Search & Destroy games from the Call of Duty World League for the 2018 and 2019 seasons.

Call of Duty World League: Search & Destroy Outcome Predictions Growing up as an avid Call of Duty player, I was always curious about what factors led

Brett Vogelsang 2 Jan 18, 2022
nn-Meter is a novel and efficient system to accurately predict the inference latency of DNN models on diverse edge devices

A DNN inference latency prediction toolkit for accurately modeling and predicting the latency on diverse edge devices.

Microsoft 241 Dec 26, 2022
This repository contains the code to predict house price using Linear Regression Method

House-Price-Prediction-Using-Linear-Regression The dataset I used for this personal project is from Kaggle uploaded by aariyan panchal. Link of Datase

null 0 Jan 28, 2022
Kaggle Competition using 15 numerical predictors to predict a continuous outcome.

Kaggle-Comp.-Data-Mining Kaggle Competition using 15 numerical predictors to predict a continuous outcome as part of a final project for a stats data

moisey alaev 1 Dec 28, 2021
Avocado hass time series vs predict price

AVOCADO HASS TIME SERIES VÀ PREDICT PRICE Trước khi vào Heroku muốn giao diện đẹp mọi người chuyển giúp mình theo hình bên dưới https://avocado-hass.h

hieulmsc 3 Dec 18, 2021
Flask app to predict daily radiation from the time series of Solcast from Islamabad, Pakistan

Solar-radiation-ISB-MLOps - Flask app to predict daily radiation from the time series of Solcast from Islamabad, Pakistan.

Abid Ali Awan 1 Dec 31, 2021
A model to predict steering torque fully end-to-end

torque_model The torque model is a spiritual successor to op-smart-torque, which was a project to train a neural network to control a car's steering f

Shane Smiskol 4 Jun 3, 2022
MLReef is an open source ML-Ops platform that helps you collaborate, reproduce and share your Machine Learning work with thousands of other users.

The collaboration platform for Machine Learning MLReef is an open source ML-Ops platform that helps you collaborate, reproduce and share your Machine

MLReef 1.4k Dec 27, 2022