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
I want a Python script demonstrating a simple approach for “shaking up” that historical data. Specifically, show me how to: | |
Load the Boston Housing dataset (or a similar publicly available dataset). | |
Split the data into training and test sets. | |
Add a small amount of random noise (jitter) to the training set features. | |
Train one linear regression model on the unmodified data and another on the jittered data. | |
Compare the MSE (Mean Squared Error) of each model on the same test set. | |
For the jitter, just use a normal distribution with a small standard deviation, something like 0.01. Then show me how the MSE differs between the original and jittered data. If the jittered version yields a lower MSE, let me know in the script output. If it’s worse, let me know that, too. | |
Nothing too fancy, just enough that I can make a point about how “bad data” might become surprisingly helpful when we own the uncertainty and inject it. And please include some print statements that display the MSEs. That’s it. |
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
You are a highly capable Python programmer who has access to locations.csv, which contains columns name, longitude, latitude, and type. | |
Please write a Python script that does the following: | |
Reads locations.csv into a pandas DataFrame. | |
Enumerates every possible Origin–Destination (OD) pair, but skips certain flows based on the following rules (via a helper function is_valid_flow(origin_type, dest_type)): | |
No shipments from Plant -> Customer | |
No shipments from DC -> Plant | |
No shipments from Customer -> DC | |
No shipments from Customer -> Plant |
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
name | longitude | latitude | type | |
---|---|---|---|---|
Washington DC | -77.0369 | 38.9072 | DC | |
Dallas TX | -96.797 | 32.7767 | DC | |
Los Angeles CA | -118.2437 | 34.0522 | DC | |
Phoenix AZ | -112.074 | 33.4484 | Plant | |
Charlotte NC | -80.8431 | 35.2271 | Plant | |
0 Washington DC | -76.16186430611484 | 38.96475995358956 | Customer | |
1 Washington DC | -77.85084407238416 | 40.23905626401316 | Customer | |
2 Washington DC | -78.33383248877686 | 37.28207518409593 | Customer | |
3 Washington DC | -77.18345675251808 | 38.38733808629542 | Customer |
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
You have a CSV file called `locations.csv` with columns: name, longitude, latitude, type (including 'Customer' rows), DCs, and plants. | |
I want you to: | |
1. Filter the data to only include rows where `type == 'Customer'`. | |
2. Generate synthetic one-period demand for these customers: | |
- Normal scenario: Draw from a normal distribution (mean=100, std=20), clip negatives at 0. |
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
Generate a Python Script for [Project Objective] Visualization with [Visualization Tools] in a Jupyter Notebook | |
Body: | |
Objective: | |
Clearly describe the purpose of the project, the type of data involved, and the key insights or lessons you aim to convey through visualization. Mention whether you have an existing dataset or need to generate synthetic data. | |
Example: | |
Create a Python script to visualize supply chain network scenarios using Folium maps. The visualization should compare an optimal distribution strategy (multiple Distribution Centers) versus a suboptimal one (single Distribution Center) to highlight the impact on costs and delivery times. If no data file is provided, generate synthetic data for Distribution Centers (DCs) and Customers. |
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
Write a Python script to generate synthetic supply chain data with the following rules: | |
Here is the detailed description based on the supply chain network: | |
Distribution Centers (DCs) | |
Washington, DC: | |
Located in the northeastern United States near major population centers. | |
Likely serves as a key hub for East Coast distribution. | |
Dallas, TX: | |
Positioned centrally in the southern United States. |
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 | |
import matplotlib.pyplot as plt | |
from ortools.constraint_solver import pywrapcp | |
from ortools.constraint_solver import routing_enums_pb2 | |
from scipy.spatial.distance import cdist | |
import matplotlib.cm as cm | |
# Set random seed for reproducibility | |
np.random.seed(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 pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import dowhy | |
from dowhy import CausalModel | |
import networkx as nx | |
import math | |
import sklearn | |
from sklearn import preprocessing | |
from sklearn.model_selection import train_test_split |
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
# Replicate Bob's results from this LinkedIn post: | |
# https://www.linkedin.com/posts/bob-wilson-77a22ab_people-sometimes-say-ab-testing-requires-activity-7152792859878871040-X1Sr?utm_source=share&utm_medium=member_desktop | |
### Implement Fisher's Exact Test | |
# Create the contingency table | |
contingency_table <- matrix(c(0, 4, 7, 3), nrow = 2) | |
dimnames(contingency_table) <- list(c("Control", "Treatment"), |
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
# Load Required Libraries | |
if (!require("MASS")) install.packages("MASS") | |
library(MASS) | |
# Define TV Shows | |
# A vector of TV show titles | |
tv_shows <- c( | |
"Breaking Bad", "Game of Thrones", "The Wire", | |
"Stranger Things", "The Crown", "Mad Men", | |
"The Sopranos", "Friends", "The Office", |
NewerOlder