Saturday 29 September 2018

TrafficControl: Improving Calculations for Acceleration

Until now. I've had a simplistic model for calculating train speeds. In this blog post, I'll refine it.

The train's desired speed is calculated as:

It is a calculation that does the job by taking the square root of the remaining distance minus the current speed. That function is mixing up the units and must be fixed.

Acceleration of trains are described by the speed-time curve:
  1. Initially, the acceleration is constant
  2. As the air resistance is increasing, the acceleration reduces and the train reaches its maximum speed.
After analysing some videos of accelerating trains, speed-time curves look as below:

I'll approximate the acceleration with a function:

  • A is the rate of acceleration for speeds below C (0.7 m/s2 in the example above)
  • B is the rate of decline of acceleration (0.02 m/s3 in the example)
  • C is the speed at which the decline starts (23 m/s in the example)

The function parameters will be different for different train types.

Retardation is harder to approximate, so I'll assume a constant retardation here.



With a constant rate of acceleration when braking, the braking distance is proportional to the speed squared:
D is a constant with a typical value of 2.

Saturday 22 September 2018

TravelTimeCalculator: Steps

I see the following steps for developing the app:
  1. Add project to GIT
  2. Display the current location on a map and print the coordinates of the device once the app starts. Done
  3. Add one button to the app so that the user can print the coordinates for the center of the map instead of the user's location.
  4. Query one direction using Google Directions API and extract the travel time from the JSON string.
  5. Query 8 points around the center for travel time for different means of transportation
  6. Learn how to add icons on the map showing the preferred option
  7. Use a database to re-use old query results
  8. Customize the search to consider travel costs and environment.
I will need to find a way to conceal my API key when pushing to GitHub.

The steps are updated at http://cutetrains.blogspot.com/p/bac.html

Saturday 15 September 2018

Book Review: Python Machine Learning Blueprints

Python Machine Learning Blueprints is written by Alexander T Combs and is illustrating how to do some machine learning, data science and advanced web scraping using Python.



It shows some real-world examples using some very useful packages:
Python Requests  - Makes it easy to send HTTP requests
Jupyter Notebook - Useful for visualizing data inspection and creating documents with live code and visualisation.
Pandas - Useful for data analysis
Matplotlib - Based on Matlab,  useful for plotting data.
Seaborn - Useful for visual analysis of data, offering for example violin diagrams.
Statsmodels - Useful for working with models and statistical tests.
Scikit Learn - Useful for visualizations, regression, model selection, clustering etc.

feedback@packtpub.com

The examples are clearly presented, along with both code and diagrams showing how the data was analyzed. Some of them are: Finding underpriced apartments, Analyzing and predicting viral content, Building an image similarity engine and more.

One flaw with the book was the chapter about deep learning. It seems that the author didn't get the numbers right, which made it very hard to follow the calculations.

The expected output isn't specified in the second section/second sentence. The weight function got W and X wrong and W2 was set to 0.2 in the text but 0.4 in the equation. This makes it very hard to follow the example.

I have some other pet projects that take time now, so I won't be able to do serious data mining/machine learning now, but once I have time to explore these topics, I'll buy this book,

Saturday 8 September 2018

TravelTimeCalculator: The Concept

The app will create a layered map that compares some different means of transportation.

It will consist of a map view that the user can pan and zoom. Upon a request from the user, the program will fetch the center coordinates. The program will select some coordinates around the center and query directions for those coordinates.

For example, we can start from Smedstorpsgatan 13 in Malmö (55.6 N, 13.05 E). I select an end coordinate at Storgatan 39B (55.6 N, 13 E).

Four different queries are made:

Driving:
The program should select the shortest of the three different proposals for driving.
Transit:

Cycling:

Walking: 

The program will compare the four different means of transportation. For the queries above, both cycling and driving gave the same results in minutes (the response to the API query will be in seconds, so this case will be unlikely). The app will display one of the best options for that target coordinate and continue with other coordinates to form a grid on the map:

(55.65 N, 13.00 E), Swim (55.65 N, 13.05 E), Bicycle (55.65 N, 13.10 E), Bicycle
(55.60 N, 13.00 E), Transit (55.60 N, 13.05 E), Starting Point (55.60 N, 13.10 E), Bicycle
(55.55 N, 13.00 E), Transit (55.55 N, 13.05 E), Driving (55.55 N, 13.10 E), Bicycle





The app will check more directions, depending on the internet connection speed for the device (future functionality).





Saturday 1 September 2018

Book Review: Superintelligence - Paths, Dangers, Strategies

Regarding AI, I was naive before reading this book. Now I'm perhaps more alarmistic.

Nick Boström is a Swedish professor in Philosophy at the University of Oxford with focus on superintelligence and the existensial risks we might face when developing agents that are far more intelligent than we humans are together.

The problem is still on a hypothetical level, and a general superintelligence will probably take time to happen, if ever. However, it is important to address the risks and find powerful safeguards (as Boström explains, this is difficult),

What's AI?
Artificial Intelligence is a buzz-word that is hard to define. One definition might be the ability to solve problems humans can solve. The field has been explored formally since a workshop on Darmouth College in 1956. Since then, there has been several periods of extensive research followed by AI winters.

There is a distinction between general and narrow AI, where narrow AI adresses more specific problems, such as chess games, trading algorithms and Apple's Siri. General AI refers to an ability to solve general problems that humans can solve. Most AI systems of today are narrow AI.

General intelligence is much more complicated to develop. This includes common sense, which is hard to formulate.

Superintelligence is an actor/agent that has an intelligence far above the most intelligent human beings.

Scales of Intelligence
Here we are biased by the human scale of intelligence, that ranges from Lloyd Christmas and Harry Dunne up to sir Isaac Newton and Ada Lovelace. This scale apply to human intelligence, but there are more life forms than that. Fungus, for example have much weaker intellectual capability than all human beings. At the other end of the scale, there might be agents with far higher intelligence than the brightest human beings.

Analogy: Human beings are generally up to two meters tall, with a world record of 272 cm. Blue whales twelve times longer has been recorded. Redwood trees can exceed 91 meters. This illustrates that human scales are very narrow. If we can meet creatures that are twelve or fourty times longer than we are, it would be possible to meet creatures twelve or fourty times more intelligent.

Types of Superintelligence
Nick Boström discusses different types of superintellligence:
  • Speed (doing what we can do but faster)
  • Collective (many smaller intellects cooperating to form a superintelligence)
  • Quiality superintelligence (doing what we can do but with better quality)
He foresees that the speed of the AI takeoff (speed for the system to gain superintelligence itself) will happen very quickly. That will happen when the system finds ways to improve its capacity, develop new code and convincing people to assign more resources to that system.

Things Getting Nasty?
An agent that is smart enough will learn how when to conceal its intelligence when it finds it suitable. It may also try to escape from its sandbox environment, for example by convincing a technician to plug in a network cable, or bring a flash disk with a copy of some data.

Boström is also discussing the goals of superintelligence systems. The targets that we give the system can easily become harmful. For example, an AI system that is supposed to make people smile can cheat by applying plastic surgery dooming people to statically grinning faces, Further, if a superintelligence has different goals than humans have, the system will find ways to secure the resources. Perhaps not nice or friendly ways.

There are several movies describing clashes between AI and humans. If we ever ceate a superintelligence powerful enough to harm us, it will probably do its homework enough not to give its opponent any chance.

AI Research
The AI research has several agents: governments, companies, criminals, academics. Many of them are in an arms-race with each other. They cannot afford losing that race, and there is a significant risk that many projects will rush themselves to reach superintelligence. There is a risk that projects will ignore the safeguards that may prevent AI from becoming harmful.

Artificial intelligence has already been used to manipulate elections. AI is changin our world now. In other countries, AI is used to rank citizens after how correct their behaviour is. I strongly recommend everyone affected by AI (everyone) to read this book.