A machine learning-based system for identifying and mitigating Fracture-Driven Interactions (FDI) in oil and gas wells.
This project uses real-time pressure data analysis to identify frac hits between wells, helping operators manage well interference issues. The system combines unsupervised time-series anomaly detection algorithms with semi-supervised machine learning to provide accurate detection of FDI events that can significantly impact well productivity and efficiency.
- Requirements
- External Dependencies
- Environmental Variables/Files
- Installation and Setup
- Usage
- Features
- Documentation
- Credits and Acknowledgments
- License
- Third-Party Libraries
- Contact Information
This code has been run and tested using the following internal and external components
- Python 3.8+
- Pandas v1.3.5
- NumPy v1.20.3
- Scikit-learn v1.0.2
- XGBoost v1.5.0
- Dash v2.0.0
- Plotly v5.5.0
- GitHub
- VS Code
- Git - Download latest version at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
- Python - Download latest version at https://www.python.org/downloads/
This system requires the following environmental data files in the data/ directory:
initial_dataset.csv: Raw time-series pressure data from wellsengineer_picked.csv: Labeled dataset of known FDI events for training
Download this code repository by using git:
git clone https://github.com/SP25-CSCE482-capstone/frac_hit_sprint_1.gitNavigate to the project directory:
cd frac_hit_sprint_1Install the required packages:
pip install -r requirements.txtProcess the data and train the model:
cd scripts
python data_ingestion_multiclass.py
python ml_model_multiclass.py
python model_predict_offset_wells.pyStart the backend dashboard:
cd app
python app.pyIn a new terminal window, set up and start the React frontend:
cd frontend
sudo npm startThe system has three main components:
- Data Ingestion: Handles raw pressure data, performs feature engineering, and prepares datasets for training.
# Load data
initial_data = pd.read_csv('data/initial_dataset.csv')
labeled_data = pd.read_csv('data/engineer_picked.csv')
# Train HMM for anomaly detection
hmm = GaussianHMM(n_components=2, covariance_type="diag", n_iter=100, random_state=42)
hmm.fit(scaled_features)
hidden_states = hmm.predict(scaled_features)
initial_data['anomaly_score'] = hidden_states
# Prepare Data for ML Model
initial_data['label'] = 0
for _, event in labeled_data.iterrows():
mask = (initial_data['time'] >= event['Start Time'] - time_window) & (initial_data['time'] <= event['End Time'] + time_window)
delta_p = event['DeltaP']
slope = event['Slope (/min)']
duration = event['Duration (min)']
if 200 <= delta_p <= 400:
initial_data.loc[mask, 'label'] = 1 # Poroelastic response
elif 400 <= delta_p <= 700:
initial_data.loc[mask, 'label'] = 2 # Indirect frac-hit response
elif 700 <= delta_p:
initial_data.loc[mask, 'label'] = 3 # Direct frac-hit response
# Save processed data
initial_data.to_csv('data/processed_data.csv', index=False)- ML Model: Trains and evaluates the XGBoost model for FDI detection.
# Load processed data
data = pd.read_csv('data/processed_data.csv')
# Prepare features and labels
features = ['moving_avg', 'slope', 'pressure_change', 'anomaly_score' , 'pressure_derivative', 'volume_to_first_response', 'pressure_relative_baseline']
X = data[features]
y = data['label'] # Multiclass labels: 0/1/2/3
# Feature scaling
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
# Apply SMOTE with controlled sampling
smote = SMOTE(sampling_strategy=sampling_strategy, random_state=42)
X_resampled, y_resampled = smote.fit_resample(X_scaled, y)
# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train model
model = XGBClassifier(
objective='multi:softprob',
num_class=4,
random_state=42,
eval_metric='mlogloss',
n_estimators=200,
max_depth=7,
learning_rate=0.1,
reg_alpha=0.1,
reg_lambda=1.0,
)
model.fit(X_train, y_train)
# Save model
joblib.dump(model, 'models/frac_hit_model.pkl')
joblib.dump(scaler, 'models/feature_scaler.pkl')- App: Interactive visualization of pressure trends and detected FDI events.
- Automated Anomaly Detection: HMM algorithm to identify anomalies in pressure data
- Feature Engineering: Creation of specialized features like moving averages, slope, and pressure change
- Semi-Supervised Learning: XGBoost classifier trained on engineer-verified FDI events
- Visualization: Dash dashboard for monitoring well pressure and detected FDI events
- Configurable Detection Sensitivity: Adjustable parameters for detection thresholds
Links to more comprehensive documentation
API references for libraries or frameworks
- Dashboard design based on Plotly's example templates
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses the following third-party libraries:
- Pandas (BSD 3-Clause License)
- NumPy (BSD 3-Clause License)
- Scikit-learn (BSD 3-Clause License)
- XGBoost (Apache 2.0 License)
- Dash (MIT License)
- Plotly (MIT License)
Any questions, contact information is below.
