Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee41cdc

Browse files
more docs
1 parent e45db84 commit ee41cdc

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

‎.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ docs/_build
1919
.vscode
2020
app/__pycache__
2121
app/data/__pycache__
22-
app/data/data_banknote_authentication.txt
22+
app/data/data_banknote_authentication.txt
23+
LICENSE
24+
README.md

‎app/data/predictions_handler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,27 @@ def get_predictions(data):
1515
:param data: Dict with keys representing features and values representing the associated value
1616
:return: Dict with keys 'predicted_class' (class predicted) and 'predicted_prob' (probability of prediction)
1717
"""
18+
# Convert new data dict as a DataFrame and reshape the columns to suit the model
1819
new_data = {k: [v] for k, v in data.items()}
1920

2021
new_data_df = pd.DataFrame.from_dict(new_data)
22+
2123
new_data_df = new_data_df[['variance_of_wavelet', 'skewness_of_wavelet',
2224
'curtosis_of_wavelet', 'entropy_of_wavelet']]
2325

26+
# Load saved standardising object
2427
scaler = joblib.load('app/data/scaler.joblib')
2528
logger.debug('Saved standardising object successfully loaded')
2629

30+
# Load saved keras model
2731
model = tf.keras.models.load_model('app/data/banknote_authentication_model.h5')
2832
logger.debug('Saved ANN model loaded successfully')
2933

34+
# Scale new data using the loaded object
3035
X = scaler.transform(new_data_df.values)
3136
logger.debug('Incoming data successfully standardised with saved object')
3237

38+
# Make new predictions from the newly scaled data and return this prediction
3339
preds = model.predict(X)
3440

3541
return preds

‎app/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def get_prediction(incoming_data: Features):
6262

6363

6464
if __name__ == "__main__":
65+
# Run app with uvicorn with port and host specified. Host needed for docker port mapping
6566
uvicorn.run(app, port=8000, host="0.0.0.0")
6667

6768

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /