Shubham Ankit

Shubham Ankit


Codeless ML with TensorFlow and AI Platform

Advances in AI frameworks enable developers to create and deploy deep learning models with as little effort as clicking a few buttons on the screen. Using a UI or an API based on Tensorflow Estimators, models can be built and served without writing a single line of machine learning code.

70 years ago, only a handful of experts knew how to create computer programs, because the process of programming required very high theoretical and technical specialization. Over the years, humans have created increasingly higher levels of abstraction and encapsulation of programming, allowing less-skilled personnel to create software with very basic tools (see Wix for example). The exact same process occurs these days with machine learning — only it advances extremely faster. In this blog post we will write down a simple script that will generate a full machine learning pipeline.

Truly codeless?

This post contains two types of code. The first is a SQL query to generate the dataset — this is the part of the code could be replaced by tools like Google Cloud Dataprep. The other type involves API calls using a Python client library — all of these actions are available through the AI platform UI. When I say codeless, I mean that at no point will you need to import TensorFlow or other ML libraries.

In this demo, I will use the Chicago Taxi Trips open dataset in Google BigQuery to predict the travel time of a taxi based on pickup location, desired drop-off, and the time of ride start. The model will be trained and deployed using Google Cloud services that wrap Tensorflow.

The entire code sample can be found in this GitHub repository.

Extract Features using BigQuery

Based on an EDA shown in this notebook, I created a SQL query to generate a training dataset:

WITH dataset AS( SELECT 

              EXTRACT(HOUR FROM  trip_start_timestamp) trip_start_hour
            , EXTRACT(DAYOFWEEK FROM  trip_start_timestamp) trip_start_weekday
            , EXTRACT(WEEK FROM  trip_start_timestamp) trip_start_week
            , EXTRACT(DAYOFYEAR FROM  trip_start_timestamp) trip_start_yearday
            , EXTRACT(MONTH FROM  trip_start_timestamp) trip_start_month
            , (trip_miles * 1.60934 ) / ((trip_seconds + .01) / (60 * 60)) trip_speed_kmph
            , trip_miles
            , pickup_latitude
            , pickup_longitude
            , dropoff_latitude
            , dropoff_longitude
            , pickup_community_area
            , dropoff_community_area
            , ST_DISTANCE(
              (ST_GEOGPOINT(dropoff_longitude,dropoff_latitude))) air_distance
            , CAST (trip_seconds AS FLOAT64) trip_seconds
        FROM `bigquery-public-data.chicago_taxi_trips.taxi_trips` 
            WHERE RAND() < (3000000/112860054) --sample maximum ~3M records 
                    AND  trip_start_timestamp < '2016-01-01'
                    AND pickup_location IS NOT NULL
                    AND dropoff_location IS NOT NULL)
            , air_distance
            , pickup_latitude
            , pickup_longitude
            , dropoff_latitude
            , dropoff_longitude
            , pickup_community_area
            , dropoff_community_area
            , trip_start_hour
            , trip_start_weekday
            , trip_start_week
            , trip_start_yearday
            , trip_start_month
        FROM dataset
        WHERE trip_speed_kmph BETWEEN 5 AND 90

feature extraction script

In the repo, you will be able to see how I execute the query using a python client and export it to GCS.

**Important! **In order for the AI platform to build a model with this data, the first column must be the target variable and the CSV export should not contain a header.

Submit hyper-parameter tuning job and deploy

After I have my dataset containing a few hundred thousand rides, I define a simple neural network architecture based on the TensorFlow Estimator API, with parameters space to search. This specific spec will create a 3 hidden-layers neural network that solves a regression task (the expected trip time). It will launch 50 trials to search optimal settings for the learning rate, regularization factors, and maximum steps.

        "scaleTier": "CUSTOM",
        "masterType": "standard_gpu",
        "args": [
        "hyperparameters": {
            "goal": "MINIMIZE",
            "params": [
                    "parameterName": "max_steps",
                    "minValue": 100,
                    "maxValue": 60000,
                    "type": "INTEGER",
                    "scaleType": "UNIT_LINEAR_SCALE"
                    "parameterName": "learning_rate",
                    "minValue": 0.0001,
                    "maxValue": 0.5,
                    "type": "DOUBLE",
                    "scaleType": "UNIT_LINEAR_SCALE"
                    "parameterName": "l1_regularization_strength",
                    "maxValue": 1,
                    "type": "DOUBLE",
                    "scaleType": "UNIT_LINEAR_SCALE"
                    "parameterName": "l2_regularization_strength",
                    "maxValue": 1,
                    "type": "DOUBLE",
                    "scaleType": "UNIT_LINEAR_SCALE"
                    "parameterName": "l2_shrinkage_regularization_strength",
                    "maxValue": 1,
                    "type": "DOUBLE",
                    "scaleType": "UNIT_LINEAR_SCALE"
            "maxTrials": 50,
            "maxParallelTrials": 10,
            "hyperparameterMetricTag": "loss",
            "enableTrialEarlyStopping": True
        "region": "us-central1",
        "jobDir": "{JOB_DIR}",
        "masterConfig": {
            "imageUri": ""

Provided the spec above I can use a Python client to launch a training job:

def train_hyper_params(cloudml_client, training_inputs):

    job_name = 'chicago_travel_time_training_{}'.format(datetime.utcnow().strftime('%Y%m%d%H%M%S'))
    project_name = 'projects/{}'.format(project_id)
    job_spec = {'jobId': job_name, 'trainingInput': training_inputs}
    response = cloudml_client.projects().jobs().create(body=job_spec,

I use the API client to monitor the job run, and, when the job is done, I deploy and test the model.

def create_model(cloudml_client):
    Creates a Model entity in AI Platform
    :param cloudml_client: discovery client
    models = cloudml_client.projects().models()
    create_spec = {'name': model_name}


def deploy_version(cloudml_client, job_results):
    Deploying the best trail's model to AI platform
    :param cloudml_client: discovery client
    :param job_results: response of the finished AI platform job
    models = cloudml_client.projects().models()

    training_outputs = job_results['trainingOutput']
    version_spec = {
        "name": model_version,
        "isDefault": False,
        "runtimeVersion": training_outputs['builtInAlgorithmOutput']['runtimeVersion'],

        # Assuming the trials are sorted by performance (best is first)
        "deploymentUri": training_outputs['trials'][0]['builtInAlgorithmOutput']['modelPath'],
        "framework": training_outputs['builtInAlgorithmOutput']['framework'],
        "pythonVersion": training_outputs['builtInAlgorithmOutput']['pythonVersion'],
        "autoScaling": {
            'minNodes': 0

    versions = models.versions()
    response = versions.create(body=version_spec,
                    parent='{}/models/{}'.format(project_name, model_name)).execute()
    return response

With this, I completed the deployment of a machine learning pipeline using only API calls.

Get predictions

In order to get predictions, I load part of the test set records to the memory and send it to the deployed version for inference:

def validate_model():
    Function to validate the model results
    df_val = pd.read_csv('{}/processed_data/test.csv'.format(job_dir))
    # Submit only 10 samples to the server, ignore the first column (=target column)
    instances = [", ".join(x) for x in df_val.iloc[:10, 1:].astype(str).values.tolist()]
    service ='ml', 'v1')
    version_name = 'projects/{}/models/{}'.format(project_id, model_name)

    if model_version is not None:
        version_name += '/versions/{}'.format(model_version)

    response = service.projects().predict(
        body={'instances': instances}

    if 'error' in response:
        raise RuntimeError(response['error'])

    return response['predictions']

Getting predictions

Originally published by*** Gad Benram ****at *

Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Learn More

Complete Guide to TensorFlow for Deep Learning with Python

Data Science: Deep Learning in Python

Python for Data Science and Machine Learning Bootcamp

Deep Learning with TensorFlow 2.0 [2019]

TensorFlow 2.0: A Complete Guide on the Brand New TensorFlow

Tensorflow and Keras For Neural Networks and Deep Learning

Tensorflow Bootcamp For Data Science in Python

Complete 2019 Data Science & Machine Learning Bootcamp

#tensorflow #python #machine-learning

What is GEEK

Buddha Community

Codeless ML with TensorFlow and AI Platform
Archie  Powell

Archie Powell


Selecting a Conversational AI Platform

Businesses are quickly acknowledging the importance of Conversational AI (CAI) to increase their customer engagement and revenues. The question is no longer whether to deploy CAI, but rather which platform to use and how to leverage its capabilities.

In this series, Daniel Eriksson, Chief Innovation and Customer Success Officer at Artificial Solutions, gives insight on important aspects of a conversational AI platform that buyers often overlook. For example: what does language support really mean? What is localization? How do different deployment models impact the TCO? And maybe most importantly, how can the CAI platform not only help me during the first development sprints, but across the entire bot lifecycle?

Making Bot Developers More Productive

During the last six months, I’ve had a lot of conversations with companies (clients) and system integrators (partners) who have been building conversational bots. I’ve spoken with conversational bot developers, data linguistics reps, integration engineers, conversational designers, project managers, senior stakeholders, product owners, and many more.

At the same time, I’ve talked to existing, new, prospective, and former clients. These talks included people who had ambitious plans and succeeded and others who have had plans where they have struggled to generate impact.

Four Perspectives to Consider When Selecting your Conversational AI Platform

Select a Tool Your Development Team Can Grow With

See past the buzz-words like “awareness”, “understanding”, and “self-learning”.

Conversational AI is a fascinating space and still holds a lot of potential that is yet to be explored. Yet most companies who have experience of CAI tooling will tell you it’s all about engineering, and actually has a lot of resemblance to regular software or process flow development instead of being something ground-breaking new.

Sure, there are some terminologies both useful and specific for the space, like “intent recognition”, “entities”, and “context”. These words are related to the Natural Language Understanding (NLU) part of a conversational bot.

Find a Balance Between Pure Coding and Drag-and-Drop

Have you ever heard about low-code or no-code? In short, those concepts describe a user interface where a developer can configure or graphically design a process instead of having to write programming code. It is a great way to visualize how a program is executed and can be a quick way to build some things rapidly. Here comes the tricky part — for an effective Conversational AI solution with some ambition, you will still need to code. Your team will need to write code in some scripting language. If not, you will not be able to do the things you expect a bot to do. Do not shy away from this fact, as scripting and coding are super important to make a bot great. So, when you look at a toolset, evaluate it from the standpoint “how will the coding part work?”

Consider Possible Future Limitations

There is a lot of CAI tooling in the market today available to developers. Your job is to make sure that you don’t select tooling that is quick to build only the first MVP but also is useful for every new generation of your bot. When your ambitions grow, and your insights on how you can deliver a better bot user experience start to develop, you might realize that the tool you chose is holding you back.

#ai #artificial intelligence #natural language processing #conversational ai #ai platform #platform

Hertha  Walsh

Hertha Walsh


Learning AI/ML: The Hard Way

The Wave and the Curve

Data science, Artificial Intelligence (AI), and Machine Learning (ML), since last five to six years these phrases have made their places in Gartner’s hype cycle curve. Gradually they have crossed the peak and moving toward the plateau. The curve also has few related terms such as Deep Neural Network, Cognitive AutoML etc. This shows that, there is an emerging technology trend around AI/ML which is going to prevail over the software industry during the coming years. Few of their predecessors such as Business Intelligence, Data Mining and Data Warehousing were there even before these years.

Finding the Crystal Ball in the Jungle

Prediction and forecasting being my favorite topics, I started finding a way to get into this world of data and algorithms back in early 2019. Another driving force for me to learn AI/ML was my fascination on neural networks that was haunting me since I started learning about computer science. I collected few books, learned some python skills to dive into the crystal ball.

While I was going through the online articles, videos and books, I discovered lots of readily available tools, libraries and APIs for AI/ML. It was like someone who is trying to learn cycling and given a car to drive. Due to my interest in neural networks, I got attracted to most the most interesting sub-set of AI/ML, Deep Learning, which deals with deep neural networks. I couldn’t stop myself from directly jumping into Google Tensorflow (a free Google ML tool) and got overwhelmed by a huge collection of its APIs. I could follow the documentation, write code and even made it work. But there was a problem, I was unable understand why I am doing what I am doing. I was completely drowning with the terms like bios, variance, parameters, feature selection, feature scaling, drop out etc. That’s when I took a break, rewind and learn about the internals of AI/ML rather than just using the APIs and Libs blindly. So, I took the hard way.

On one side, I was allured by the readily available smart AI/ML tools and on the other side, my fascination on neural networks was attracting me to learn it from scratch. Meanwhile, I have spent around a month or two just looking for a path to enter the subject. A huge pool of internet resources made me thoroughly confused in identifying the doorway to the heart of puzzle. I realized, why it is a hard nut for people to learn. Janakiram MSV pointed out the reasons correctly in his article.

However, some were very useful, such as an Introduction to Machine Learning by Prof. Grimson from MIT OpenCourseWare. Though its little long but helpful.

#machine learning #ai #artificial intelligence (ai) #ml #ai guide #ai roadmap

Otho  Hagenes

Otho Hagenes


Making Sales More Efficient: Lead Qualification Using AI

If you were to ask any organization today, you would learn that they are all becoming reliant on Artificial Intelligence Solutions and using AI to digitally transform in order to bring their organizations into the new age. AI is no longer a new concept, instead, with the technological advancements that are being made in the realm of AI, it has become a much-needed business facet.

AI has become easier to use and implement than ever before, and every business is applying AI solutions to their processes. Organizations have begun to base their digital transformation strategies around AI and the way in which they conduct their business. One of these business processes that AI has helped transform is lead qualifications.

#ai-solutions-development #artificial-intelligence #future-of-artificial-intellige #ai #ai-applications #ai-trends #future-of-ai #ai-revolution

George  Koelpin

George Koelpin


AI: Right Structure of Agents For your Business

In this post let us talk about the types of agents and challenges of data set for the agents.

All agents have the same skeletal structure. They get percepts as inputs from the sensors and the actions are performed through the actuators. Now the agent can either just act on a percept as a reflex for example if you throw a ball at me and I try to catch it (or duck from it given that I am bad at baseball) than that is a quick reaction to the percept. On the other hand if you throw a ball at me and tell me to arrange it by color or count the number different colors that you are throwing at me then I would have to maintain a state to do the counts correctly. So this would involve some state but is still ok. Now, if you want to trouble me further and you tell me to jump twice if you throw red ball at me and do a burpee if you throw a green ball at me apart from catching and counting then you got me for sure

This would involve a complex logic of me maintaining a mind table of what needs to be done on what percept and this is called** condition-action rule**. Now if all these percepts were to be indexed then this would become a significant data set.

Consider the automated taxi: the visual input from a single camera (eight cameras is typical) comes in at the rate of roughly 70 megabytes per second (30 frames per second, 1080 × 720 pixels with 24 bits of color information). This gives a lookup table with over 10 600,000,000,000 entries for an hour’s driving. Even the lookup table for chess—a tiny, well-behaved fragment of the real world—has (it turns out) at least 10 150 entries.

This can become a lot of information.

The key challenge for AI is to find out how to write programs that, to the extent possible, produce rational behavior from a smallish program rather than from a vast table.

So this brings us to 4 documented types of agent programs

#ai #ml # ai and data engineering #scala #ai and ml

Murray  Beatty

Murray Beatty


This Week in AI | Rubik's Code

Every week we bring to you the best AI research papers, articles and videos that we have found interesting, cool or simply weird that week.

#ai #this week in ai #ai application #ai news #artificaial inteligance #artificial intelligence #artificial neural networks #deep learning #machine learning #this week in ai