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 StratifiedShuffleSplit | |
split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42) | |
for train_ix, test_ix in split.split(insurance, insurance['sex']): | |
train_set = insurance.loc[train_ix] | |
test_set = insurance.loc[test_ix] |
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
%matplotlib inline | |
import matplotlib.pyplot as plt | |
categorical_columns = ['sex', 'smoker', 'region'] | |
plt.figure(figsize=(15,5)) | |
for i, c in enumerate(categorical_columns): | |
plt.subplot(1, 3, i+1) | |
plt.title(c) |
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
insurance.info() |
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
insurance.head() |
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 pandas as pd | |
insurance = pd.read_csv('insurance.csv) |
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
# Python ≥3.5 is required | |
import sys | |
assert sys.version_info >= (3, 5) | |
# Scikit-Learn ≥0.20 is required | |
import sklearn | |
assert sklearn.__version__ >= "0.20" | |
# Common imports | |
import numpy as np |
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
@method_decorator(csrf_exempt, name='dispatch') | |
class OrderCompleteHook(generics.GenericAPIView): | |
def post(self, request, *args, **kwargs): | |
stripe.api_key = settings.STRIPE_SECRET_KEY | |
endpoint_secret = settings.STRIPE_ENDPOINT_SECRET | |
payload = request.body | |
sig_header = request.META['HTTP_STRIPE_SIGNATURE'] | |
event = None | |
try: |
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
<div class="card-body"> | |
<h6>${{ product.price }}</h6> | |
<button class="btn btn-primary" onclick="onBuyClick({{ product.id }})">Buy</button> | |
</div> |
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
<script src="https://js.stripe.com/v3/"></script> | |
<script> | |
let stripe; | |
fetch("/stripe-config/") | |
.then(res => { | |
return res.json(); | |
}) | |
.then(data => { | |
console.log(data); | |
stripe = Stripe(data.publicKey); |
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
urlpatterns = [ | |
path('checkout/<int:product>/', views.Checkout.as_view()), | |
] |