Kotlin provides the ability to extend a class with new functionality without having to inherit from the class or use design patterns such as Decorator. This is done via special declarations called extensions.

Models in Kotlin with data classes are already leaner and cleaner than their Java counterparts. Abstracting away all those getters, setters, toString() and copy() a method with a single keyword makes our models reflect the only thing they should be concerned about — holding data.’

A simple data class in our project is the purest form of a model we can have. I mean, look at this:

Airline customer service improved in 2020, rising to its highest level since 1994. That’s right, air travel got better while the world fell apart, at least according to the latest numbers from the American Customer Satisfaction Index (ACSI), a closely-watched barometer for customer service.

Explore how accurate can k-NN, Logistic regression and Linear Support Vector Machine can forecast. Determine the optimal parameter for each method and the top predictors.

Import required libraries

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
from warnings import simplefilter
from sklearn.exceptions import ConvergenceWarning
warnings.filterwarnings("ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category=RuntimeWarning)
warnings.filterwarnings("ignore", category=ConvergenceWarning)

Exploratory Data Analysis

source: https://www.kaggle.com/teejmahal20/airline-passenger-satisfaction

df_UPCAT = pd.read_csv('airline-dataset.csv')
dummy = df_UPCAT

While COVID-19 continues to threaten different sectors of the economy, “no industry has seen a bigger impact than airlines”. Among the hardest hit might be AirAsia, It cut capacity across its airline units by 19% in the first quarter of 2020, and passenger numbers fell 22%. Load factor was still “within expectations” at 77%.

Data Preparation

The dataset contains about 130,000 survey records and passenger details from a US airline. Passengers rate the flight experience on a scale of 1 to 5.

Gender: Gender of the passengers (Female, Male)
Customer Type: The customer type (Loyal customer, disloyal customer)
Age: The actual age of the passengers
Type of Travel: Purpose of the flight of the passengers (Personal Travel, Business Travel)
Class: Travel class in the plane of the passengers (Business, Eco, Eco Plus)
Flight distance: The flight distance of this journey
Inflight wifi service: Satisfaction level of the inflight wifi service (0:Not Applicable;1-5)
Departure/Arrival time convenient: Satisfaction level of Departure/Arrival time convenient
Ease of Online…


  • Submit your information and wait for the approval.

Make sure you add the following dependencies:

implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0'
implementation 'com.jakewharton.rxbinding3:rxbinding-core:3.0.0'

Add this extension function:

fun View.doubleClick(onComplete: () -> Unit): Disposable {
val timeout = 400L
val timeUnits = TimeUnit.MILLISECONDS
observable = this.clicks().share()
return observable.buffer(observable.debounce(timeout, timeUnits))
.subscribe {
(it.size == 2) onComplete.invoke()

It counts the number of clicks in given time e.g. timeout and timeUnits when the size is equal to2 it invoke the onComplete function.

Install java8

$ /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew tap caskroom/versions
$ brew cask install adoptopenjdk/openjdk/adoptopenjdk8

Select java8

$ /usr/libexec/java_home -V
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

If you wish not to pass context from your activity going to your Presenters and ViewModels when saving or retrieving your key-value data from SharedPreferences this might help you.

In your Application context:

public class MyApplication extends Application {

private static Context context;

@Override public void onCreate() {
context = getApplicationContext();

public static Context getContext() {
return context;



I created a sample SharedPreferenceData class where you can save and retrieve your key-value data.

public class SharePreferenceData {

private static final String TOKEN = "token";

private SharedPreferences sharedPreferences;

public static SharePreferenceData getInstance()…

Ariel Silva

Tech Lead | Product Design | Digital Innovation

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store