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
# Step 1: Convert all interactions to a list | |
journeys = campaign_data.groupby('customer_id')['channel'].aggregate( | |
lambda x: x.tolist()).reset_index() | |
# Step 2: Add last interaction as 1 or 0 event representing activation | |
activation_results = campaign_data.drop_duplicates('customer_id', keep='last')[['customer_id', 'activation']] | |
journeys = pd.merge(journeys, activation_results, how='left', on='customer_id') | |
# Step 3: Add start and end states based on whether customer activated | |
journeys['path'] = np.where( |
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 | |
import pandas as pd | |
campaign_data = pd.read_csv("cashback_activation_data.csv") | |
campaign_data = campaign_data.sort_values(['customer_id', 'timestamp'], | |
ascending=[False, True]) | |
campaign_data['visit_order'] = campaign_data.groupby('customer_id').cumcount() + 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
## LAMNDA FUNCTION lambda_function.py | |
import boto3 | |
import json | |
# grab environment variables | |
ENDPOINT_NAME = "jumpstart-dft-meta-textgeneration-llama-2-7b-rs" | |
runtime= boto3.client('runtime.sagemaker') | |
def lambda_handler(event, context): |
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
Variable | Definition | |
---|---|---|
User_ID | User ID | |
Product_ID | Product ID | |
Gender | Sex of User | |
Age | Age in bins | |
Occupation | Occupation (Masked) | |
City_Category | Category of the City (A,B,C) | |
Stay_In_Current_City_Years | Number of years stay in current city | |
Marital_Status | Marital Status | |
Product_Category_1 | Product Category (Masked) |
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 | |
import scipy.optimize | |
from sklearn.linear_model import Ridge | |
from sklearn.isotonic import IsotonicRegression | |
from sklearn.base import BaseEstimator, RegressorMixin | |
class MonotonicRegression(BaseEstimator, RegressorMixin): | |
""" Smooth increasing piecewise linear regression. | |
During training, it minimizes MSE and the sum of absolute changes in its slope. |
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 pymc3 as pm | |
from theano import tensor as tt | |
import arviz as az | |
import numpy as np | |
# Binary, correct answer array | |
scores = np.array([1,1,1,0,0,0 | |
]).flatten() | |
# (student:question) tuples |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Call the estimator with the main parameters | |
from sagemaker.estimator import Estimator | |
estimator = Estimator( | |
image_uri=ecr_image, | |
role=role, | |
instance_count=1, | |
instance_type="ml.c4.xlarge", | |
output_path=out_path |