Data Science

Deploying R Model as API Web Service using Docker and Microsoft Azure

Objective Our goal here is to create a R Model and put-in into production by deploying it as web service API using Docker to containerize (encapsulate) it and Microsoft Azure to host it. R Model To create the model, we going to use mtcars dataset which one’s is present inside R. head(mtcars) ## mpg cyl disp hp drat wt qsec vs am gear carb ## Mazda RX4 21.0 6 160 110 3.

Continue reading

Credit Card Fraud Detection

Objective Our goal is to train a Neural Network to detect fraudulent credit card transactions in a dataset referring to two days transactions by european cardholders. Source: https://www.kaggle.com/mlg-ulb/creditcardfraud/data Data credit = read.csv(path) The datasets contains transactions made by credit cards in September 2013 by european cardholders. This dataset presents transactions that occurred in two days. As we can see, this dataset consists of thirty explanatory variables, and a response variable which represents whether a transation was a fraud or not.

Continue reading

Intermediate Importing Data in Python

1. Importing flat files from the web: your turn! # Import package from urllib.request import urlretrieve # Import pandas import pandas as pd # Assign url of file: url url = 'https://s3.amazonaws.com/assets.datacamp.com/production/course_1606/datasets/winequality-red.csv' # Save file locally urlretrieve(url, 'winequality-red.csv') # Read file into a DataFrame and print its head ## ('winequality-red.csv', <http.client.HTTPMessage object at 0x000000001FBF52C8>) df = pd.read_csv('winequality-red.csv', sep=';') print(df.head()) ## fixed acidity volatile acidity citric acid ... sulphates alcohol quality ## 0 7.

Continue reading

Introduction to Importing Data in Python

1. Importing entire text files # Open a file: file file = open('c:/blogdown/moby_dick.txt', mode='r') # Print it print(file.read()) # Check whether file is closed ## CHAPTER 1. Loomings. ## ## Call me Ishmael. Some years ago--never mind how long precisely--having ## little or no money in my purse, and nothing particular to interest me on ## shore, I thought I would sail about a little and see the watery part of ## the world.

Continue reading

Supervised Learning with Scikit-Learn

1. The Iris dataset in scikit-learn from sklearn import datasets import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.style.use('ggplot') iris = datasets.load_iris() type(iris) ## <class 'sklearn.utils.Bunch'> print(iris.keys()) ## dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names', 'filename']) print(iris.DESCR) ## .. _iris_dataset: ## ## Iris plants dataset ## -------------------- ## ## **Data Set Characteristics:** ## ## :Number of Instances: 150 (50 in each of three classes) ## :Number of Attributes: 4 numeric, predictive attributes and the class ## :Attribute Information: ## - sepal length in cm ## - sepal width in cm ## - petal length in cm ## - petal width in cm ## - class: ## - Iris-Setosa ## - Iris-Versicolour ## - Iris-Virginica ## ## :Summary Statistics: ## ## ============== ==== ==== ======= ===== ==================== ## Min Max Mean SD Class Correlation ## ============== ==== ==== ======= ===== ==================== ## sepal length: 4.

Continue reading

Python Data Science - part 1

1. Single Parameter Function # Define shout with the parameter, word def shout(word): """Print a string with three exclamation marks""" # Concatenate the strings: shout_word shout_word = word + '!!!' # Print shout_word print(shout_word) # Call shout with the string 'congratulations' shout("Congratulations") ## Congratulations!!! 2. Functions that return single values # Define shout with the parameter, word def shout(word): """Return a string with three exclamation marks""" # Concatenate the strings: shout_word shout_word = word + "!

Continue reading