This file contains hidden or 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
# your client is so famous that has a dataset already in sklearn | |
from sklearn.datasets import load_boston | |
boston_dataset = load_boston() | |
df = pd.DataFrame(boston_dataset.data, columns=boston_dataset.feature_names) |
This file contains hidden or 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 seaborn as sns | |
import matplotlib.pyplot as plt | |
# seaborn histogram | |
sns.distplot(boston_dataset.target, hist=True, kde=True, | |
bins=30, color = 'blue', | |
hist_kws={'edgecolor':'black'}) | |
# Add labels | |
plt.title('Histogram of target variable') | |
plt.xlabel('House examples') |
This file contains hidden or 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
correlation_matrix = df.corr().round(2) | |
# annot = True to print the values inside the square | |
sns.heatmap(data=correlation_matrix, annot=True); |
This file contains hidden or 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.model_selection import train_test_split | |
X = pd.DataFrame(np.c_[df[df.columns[:-1]]], columns = df.columns[:-1]) | |
Y = df.target | |
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2, random_state=42) |
This file contains hidden or 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 numpy as np | |
from sklearn.model_selection import train_test_split | |
config = { | |
'data': data, | |
'train_test_ratio': 0.2 | |
} | |
def feature_selection(data): | |
""" |
This file contains hidden or 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 tensorflow as tf | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Dense, Dropout | |
num_features = X_train.shape[1] | |
config = { | |
'data': data, | |
'train_test_ratio': 0.2, | |
'model_config': { |
This file contains hidden or 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
config = { | |
'data': data, | |
'train_test_ratio': 0.2, | |
'model_config': { | |
'model_name': 'house_pricing_model', | |
'layers': { | |
'first_layer': 12, | |
'second_layer': 5, | |
'output_layer': 1 | |
}, |
This file contains hidden or 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 fastapi import FastAPI, HTTPException | |
from ai.services import get_predictions | |
from core import config | |
from schemas.schemas import InputData, ResponseDataAPI | |
app = FastAPI(title=config.PROJECT_NAME, version=config.VERSION, openapi_url="/v1/openapi.json") | |
@app.get("/status") |
This file contains hidden or 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 os | |
from tensorflow.keras.models import load_model | |
from .services import | |
class PriceEstimator: | |
""" | |
PriceEstimator object to collect prediction methods to be accessed | |
by API services. | |
""" |
This file contains hidden or 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 numpy as np | |
from sklearn.model_selection import train_test_split | |
config = { | |
'data': data, | |
'train_test_ratio': 0.2 | |
} | |
def feature_selection(data): | |
""" |