This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WaiterAge | GroupSize | DinersAvgAge | CostOfMeal | Country | Tip | |
---|---|---|---|---|---|---|
19 | 2 | 25.5 | 120 | USA | 24 | |
43 | 2 | 33 | 120 | England | 10.8 | |
34 | 3 | 42 | 132 | France | 1.32 | |
42 | 4 | 50 | 216 | Israel | 32.4 | |
29 | 5 | 50 | 220 | USA | 39.6 | |
27 | 6 | 43 | 606 | England | 12.12 | |
32 | 7 | 63 | 546 | England | 49.14 | |
34 | 8 | 55 | 712 | Israel | 71.2 | |
37 | 3 | 43 | 336 | France | 10.08 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Predict how much tip will get per our clients age | |
# Using a simple linear regression model | |
dataset = read.csv('tip.csv') | |
library(caTools) | |
# choose random number for the see | |
set.seed(100) | |
# Split the dataset between test and train set | |
split = sample.split(dataset$Tip, SplitRatio = 2/3) | |
training_set = subset(dataset, split == TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import python packages | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from sklearn.linear_model import LinearRegression | |
from sklearn.model_selection import train_test_split | |
# Load our dataset from a csv | |
dataset = pd.read_csv('tip.csv') | |
# Fetch the age column | |
age = dataset.iloc[:, :-1].values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import the dataset | |
dataset = read.csv('Data.csv') | |
# missing values | |
dataset$Age = ifelse(is.na(dataset$Age), | |
ave(dataset$Age, FUN = function(x) mean(x, na.rm=TRUE)), | |
dataset$Age) | |
dataset$Salary = ifelse(is.na(dataset$Salary), | |
ave(dataset$Salary, FUN = function(x) mean(x, na.rm = TRUE)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import sklearn as sk | |
# import the dataset | |
dataset = pd.read_csv(‘db.csv’) | |
# Load all columns into matrix but not the last ones | |
x = dataset.iloc[0:12,0:5].values | |
# Last column from the dataset | |
y = dataset.iloc[0:12,6].values | |
# Use the mean for fill missing data | |
imputer = sk.preprocessing.Imputer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Query = ‘select * from users’; | |
const pool = server.plugins[‘hapi - plugin - pg’].pg; | |
pool.query(Query, (err, res) => { | |
if (err) { //do something | |
} | |
pool.end(); // this is important | |
return res; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
‘ | |
use strict’; | |
const Hapi = require(‘hapi’); | |
const Joi = require(‘joi’); | |
const server = new Hapi.Server(); | |
server.connection({ | |
port: 3000, | |
host: ‘localhost’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Parameters: | |
NotificationEmail: | |
Type: String | |
Resources: | |
CloudTrailEventProcessing: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
phases: | |
install: | |
commands: | |
- echo Installing Mocha... | |
- npm install -g mocha | |
pre_build: | |
commands: | |
- echo Installing source NPM dependencies... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Memwatch = require('memwatch-next'); | |
const Util = require('util'); | |
if (Config.env === 'production') { | |
/** | |
* Check for memory leaks | |
*/ | |
let hd = null; | |
Memwatch.on('leak', (info) => { |