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 Flask class from the flask module | |
from flask import Flask, request | |
import numpy as np | |
import pickle | |
# Create Flask object to run | |
app = Flask(__name__) | |
@app.route('/') |
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
from sklearn.metrics import mean_squared_log_error | |
import numpy as np | |
rmsle = np.sqrt(mean_squared_log_error(y_actual, y_hat)) |
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
from sklearn.metrics import mean_squared_error | |
import numpy as np | |
rmse = np.sqrt(mean_squared_error(y_actual, y_hat)) |
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
from sklearn.metrics import mean_squared_error | |
mse = mean_squared_error(y_actual, y_hat) |
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 | |
managerDF = pd.DataFrame({'id':[101, 102, 103, 104, 105, 106, 107, 108], | |
'managerId':['D025', 'A010', 'C020', 'A010', 'D025', 'D025','A010', 'D025']}) | |
managerDF['managerIdCount'] = managerDF['managerId'].map(managerDF.groupby('managerId').size()) | |
managerDF.drop(['managerId'], axis=1, inplace=True) | |
print(managerDF) |
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
# Set number of splits | |
NO_SPLITS = fulldata.shape[0] | |
# Create KFold object with number of splits | |
kf = KFold(n_splits=NO_SPLITS) |
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 | |
from sklearn import datasets | |
from sklearn.model_selection import KFold | |
from sklearn.linear_model import LogisticRegression | |
# Import breast cancer (dataset) object from sklearn library | |
breast_cancer = datasets.load_breast_cancer() | |
# Define features need to be extracted from breast cancer (dataset) object |
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 | |
from sklearn import datasets | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LogisticRegression | |
# Import breast cancer (dataset) object from sklearn library | |
breast_cancer = datasets.load_breast_cancer() | |
# Define features need to be extracted from breast cancer (dataset) object |
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 | |
managerDF = pd.DataFrame({'id':[101, 102, 103, 104, 105, 106, 107, 108], | |
'managerId':['D025', 'A010', 'C020', 'A010', 'D025', 'D025','A010', 'D025']}) | |
# Group by category (managerId), compute sum of values in the category, sort by sum, and rank each value | |
idRank = managerDF.groupby('managerId').size().sort_values().rank().map(int) | |
# Map the ranks of items in the category to its respective item | |
managerDF['managerIdRank'] = managerDF['managerId'].map(idRank) |
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 | |
from sklearn import preprocessing | |
countryDF = pd.DataFrame({'id' : [101, 102, 103], | |
'country' : ['NZ', 'BR', 'US']}) | |
labelEncode = preprocessing.LabelEncoder() | |
countryDF['countryLabel'] = labelEncode.fit_transform(countryDF['country']) | |
countryDF.drop(['country'], axis=1, inplace=True) | |
print(countryDF) |
NewerOlder