臨床數據挖掘與分析:利用GPU加速Pandas和Scikit-learn處理大規模數據集

點擊AladdinEdu,同學們用得起的【H卡】算力平臺”,注冊即送-H卡級別算力80G大顯存按量計費靈活彈性頂級配置學生更享專屬優惠


摘要

隨著電子健康記錄(EHR)的普及和醫療信息化的深入,臨床數據分析面臨著前所未有的數據規模挑戰。傳統的基于CPU的Pandas和Scikit-learn在處理百萬級甚至千萬級患者記錄時,往往耗時過長,成為醫療科研和臨床決策的瓶頸。本文將深入探討如何利用RAPIDS生態系統中的cuDF(GPU加速的Pandas)cuML(GPU加速的Scikit-learn) 來高效處理大規模臨床數據集。通過完整的代碼示例和性能對比,展示GPU加速如何將數據處理和機器學習訓練時間從數小時縮短到數分鐘,為臨床研究人員提供切實可行的大規模數據分析解決方案。

1. 引言:臨床數據分析的挑戰與機遇

1.1 臨床數據的爆炸式增長

現代醫療系統每天產生海量數據:

  • 電子健康記錄(EHR):單個大型醫院可能擁有數百萬患者的診療記錄
  • 醫學影像數據:CT、MRI等影像檢查產生的結構化報告和數據
  • 基因組學數據:隨著精準醫療發展,基因測序數據量呈指數增長
  • 實時監測數據:ICU監護設備、可穿戴設備產生的連續生理參數

1.2 傳統分析方法的局限性

基于CPU的Pandas和Scikit-learn在處理大規模臨床數據時面臨諸多挑戰:

  • 內存限制:大型數據集無法一次性加載到內存中
  • 計算速度:復雜操作和機器學習訓練耗時過長
  • 迭代效率:臨床研究需要多次迭代和參數調優,等待時間累積顯著

1.3 GPU加速的解決方案

NVIDIA的RAPIDS生態系統提供了直接的解決方案:

  • cuDF:完全兼容Pandas API的GPU數據幀庫
  • cuML:提供Scikit-learn兼容的GPU加速機器學習算法
  • cuGraph:GPU加速的圖分析庫,適用于患者關系網絡分析

2. 環境搭建與配置

2.1 硬件要求

組件最低要求推薦配置說明
GPUNVIDIA Pascal架構(GTX 10系列)NVIDIA Ampere架構(RTX 30系列/A100)顯存越大,能處理的數據集越大
內存16 GB64 GB+系統內存應至少為GPU顯存的2倍
存儲100 GB HDD1 TB NVMe SSD快速存儲能顯著加速數據加載

2.2 軟件環境配置

# 使用Docker快速部署RAPIDS環境(推薦)
docker pull rapidsai/rapidsai-core:23.06-cuda11.8-py3.10
docker run --gpus all --rm -it -p 8888:8888 -p 8787:8787 -p 8786:8786 \-v /path/to/your/data:/data \rapidsai/rapidsai-core:23.06-cuda11.8-py3.10# 或者使用conda手動安裝
conda create -n rapids-23.06 -c rapidsai -c nvidia -c conda-forge \rapids=23.06 python=3.10 cuda-version=11.8
conda activate rapids-23.06

2.3 驗證安裝

import cudf
import cuml
import cupy as cpprint("cuDF版本:", cudf.__version__)
print("cuML版本:", cuml.__version__)
print("可用GPU內存:", cp.cuda.Device().mem_info)# 創建測試DataFrame驗證安裝
df = cudf.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
print(df)

3. 臨床數據加載與預處理

3.1 數據加載優化

臨床數據通常以CSV、Parquet或數據庫形式存儲:

import cudf
import time# 記錄開始時間
start_time = time.time()# 加載大型CSV文件(假設有1000萬行)
ehr_data = cudf.read_csv('/data/ehr_records_10m.csv', dtype={'patient_id': 'str','diagnosis_code': 'str','medication_code': 'str'},low_memory=False)# 顯示加載時間和數據概覽
load_time = time.time() - start_time
print(f"數據加載耗時: {load_time:.2f} 秒")
print(f"數據集形狀: {ehr_data.shape}")
print(f"內存使用: {ehr_data.memory_usage(deep=True).sum() / 1024**2:.2f} MB")# 查看前幾行數據
print(ehr_data.head())

3.2 數據清洗與轉換

臨床數據清洗的常見操作GPU加速:

# 處理缺失值
def clean_clinical_data(df):"""臨床數據清洗函數"""# 刪除全為空值的列df = df.dropna(axis=1, how='all')# 數值列的缺失值填充numeric_cols = df.select_dtypes(include=['number']).columnsfor col in numeric_cols:if df[col].null_count > 0:# 使用中位數填充臨床數值數據df[col] = df[col].fillna(df[col].median())# 分類列的缺失值處理categorical_cols = df.select_dtypes(include=['object']).columnsfor col in categorical_cols:if df[col].null_count > 0:# 使用眾數填充分類數據mode_value = df[col].mode()[0] if len(df[col].mode()) > 0 else 'Unknown'df[col] = df[col].fillna(mode_value)# 處理異常值(基于臨床合理范圍)df = handle_clinical_outliers(df)return dfdef handle_clinical_outliers(df):"""處理臨床異常值"""# 心率合理范圍:30-250 bpmif 'heart_rate' in df.columns:df['heart_rate'] = df['heart_rate'].clip(30, 250)# 血壓收縮壓合理范圍:60-250 mmHgif 'systolic_bp' in df.columns:df['systolic_bp'] = df['systolic_bp'].clip(60, 250)# 體溫合理范圍:35-42攝氏度if 'temperature' in df.columns:df['temperature'] = df['temperature'].clip(35, 42)return df# 執行數據清洗
cleaned_data = clean_clinical_data(ehr_data)

3.3 特征工程

臨床特征工程的GPU加速實現:

from datetime import datetimedef create_clinical_features(df):"""創建臨床特征"""# 時間特征提取if 'admission_date' in df.columns:df['admission_year'] = df['admission_date'].dt.yeardf['admission_month'] = df['admission_date'].dt.monthdf['admission_day'] = df['admission_date'].dt.daydf['admission_dayofweek'] = df['admission_date'].dt.dayofweek# 年齡分組(臨床常用分組)if 'age' in df.columns:df['age_group'] = df['age'].apply(lambda x: ' pediatric' if x < 18 else'adult' if x < 65 else'geriatric')# 創建臨床指標if all(col in df.columns for col in ['systolic_bp', 'diastolic_bp']):df['map'] = df['diastolic_bp'] + (df['systolic_bp'] - df['diastolic_bp']) / 3  # 平均動脈壓# 實驗室指標比值if all(col in df.columns for col in ['ast', 'alt']):df['ast_alt_ratio'] = df['ast'] / df['alt']return df# 應用特征工程
featured_data = create_clinical_features(cleaned_data)

4. 數據分析與探索

4.1 描述性統計分析

def clinical_descriptive_analysis(df):"""臨床描述性分析"""print("=== 數據集概覽 ===")print(f"總記錄數: {len(df):,}")print(f"患者數: {df['patient_id'].nunique():,}")print(f"時間范圍: {df['admission_date'].min()}{df['admission_date'].max()}")print("\n=== 數值變量統計 ===")numeric_stats = df.select_dtypes(include=['number']).describe()print(numeric_stats)print("\n=== 分類變量分布 ===")categorical_cols = df.select_dtypes(include=['object']).columnsfor col in categorical_cols[:5]:  # 顯示前5個分類變量print(f"\n{col} 分布:")print(df[col].value_counts().head(10))return numeric_stats# 執行描述性分析
stats_results = clinical_descriptive_analysis(featured_data)

4.2 時間序列分析

臨床數據往往包含豐富的時間信息:

def analyze_temporal_trends(df):"""分析時間趨勢"""# 按時間聚合daily_admissions = df.groupby(df['admission_date'].dt.date).size()monthly_admissions = df.groupby([df['admission_date'].dt.year, df['admission_date'].dt.month]).size()# 疾病季節趨勢seasonal_diagnosis = df.groupby([df['admission_date'].dt.month,'primary_diagnosis']).size().reset_index(name='count')return {'daily': daily_admissions,'monthly': monthly_admissions,'seasonal': seasonal_diagnosis}# 分析時間趨勢
temporal_analysis = analyze_temporal_trends(featured_data)

5. 機器學習模型構建

5.1 數據準備

from cuml.preprocessing import LabelEncoder, StandardScaler
from cuml.model_selection import train_test_splitdef prepare_ml_data(df, target_column):"""準備機器學習數據"""# 分離特征和目標X = df.drop(columns=[target_column])y = df[target_column]# 編碼分類變量label_encoders = {}categorical_cols = X.select_dtypes(include=['object']).columnsfor col in categorical_cols:le = LabelEncoder()X[col] = le.fit_transform(X[col])label_encoders[col] = le# 標準化數值特征numeric_cols = X.select_dtypes(include=['number']).columnsscaler = StandardScaler()X[numeric_cols] = scaler.fit_transform(X[numeric_cols])# 劃分訓練測試集X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)return X_train, X_test, y_train, y_test, label_encoders, scaler# 準備數據(示例:預測住院時間)
X_train, X_test, y_train, y_test, encoders, scaler = prepare_ml_data(featured_data, 'length_of_stay'
)

5.2 模型訓練與評估

from cuml.linear_model import LinearRegression
from cuml.ensemble import RandomForestRegressor
from cuml.metrics import mean_absolute_error, mean_squared_error
import timedef train_and_evaluate_models(X_train, X_test, y_train, y_test):"""訓練和評估多個模型"""results = {}# 線性回歸print("訓練線性回歸...")start_time = time.time()lr = LinearRegression()lr.fit(X_train, y_train)lr_pred = lr.predict(X_test)lr_time = time.time() - start_timelr_mae = mean_absolute_error(y_test, lr_pred)lr_rmse = mean_squared_error(y_test, lr_pred, squared=False)results['linear_regression'] = {'mae': lr_mae,'rmse': lr_rmse,'time': lr_time}# 隨機森林print("訓練隨機森林...")start_time = time.time()rf = RandomForestRegressor(n_estimators=100, max_depth=10, random_state=42)rf.fit(X_train, y_train)rf_pred = rf.predict(X_test)rf_time = time.time() - start_timerf_mae = mean_absolute_error(y_test, rf_pred)rf_rmse = mean_squared_error(y_test, rf_pred, squared=False)results['random_forest'] = {'mae': rf_mae,'rmse': rf_rmse,'time': rf_time}return results# 訓練和評估模型
model_results = train_and_evaluate_models(X_train, X_test, y_train, y_test)# 打印結果
for model_name, metrics in model_results.items():print(f"\n{model_name}:")print(f"  MAE: {metrics['mae']:.3f}")print(f"  RMSE: {metrics['rmse']:.3f}")print(f"  訓練時間: {metrics['time']:.2f} 秒")

5.3 深度學習模型

對于更復雜的臨床預測任務:

from cuml.neighbors import KNeighborsClassifier
from cuml.svm import SVC
from cuml.naive_bayes import MultinomialNBdef train_dl_models(X_train, X_test, y_train, y_test):"""訓練深度學習風格模型"""dl_results = {}# K近鄰print("訓練K近鄰...")knn = KNeighborsClassifier(n_neighbors=5)knn.fit(X_train, y_train)knn_score = knn.score(X_test, y_test)dl_results['knn'] = knn_score# 支持向量機print("訓練支持向量機...")svm = SVC(kernel='rbf', C=1.0)svm.fit(X_train, y_train)svm_score = svm.score(X_test, y_test)dl_results['svm'] = svm_scorereturn dl_results# 訓練深度學習模型
dl_results = train_dl_models(X_train, X_test, y_train, y_test)
print("深度學習模型準確率:", dl_results)

6. 性能對比與分析

6.1 GPU vs CPU 性能測試

import pandas as pd
from sklearn.ensemble import RandomForestRegressor as CPURandomForest
import timedef compare_gpu_cpu_performance(gpu_df, sample_size=100000):"""對比GPU和CPU性能"""# 采樣數據用于公平比較sample_data = gpu_df.to_pandas().sample(sample_size, random_state=42)# 準備數據X = sample_data.drop('length_of_stay', axis=1)y = sample_data['length_of_stay']# 編碼分類變量(CPU)categorical_cols = X.select_dtypes(include=['object']).columnsfor col in categorical_cols:X[col] = pd.factorize(X[col])[0]X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)# CPU訓練print("CPU訓練中...")start_time = time.time()cpu_rf = CPURandomForest(n_estimators=100, max_depth=10, random_state=42, n_jobs=-1)cpu_rf.fit(X_train, y_train)cpu_time = time.time() - start_time# GPU訓練(使用相同數據)gpu_sample = cudf.from_pandas(sample_data)X_gpu = gpu_sample.drop('length_of_stay')y_gpu = gpu_sample['length_of_stay']X_train_gpu, X_test_gpu, y_train_gpu, y_test_gpu = train_test_split(X_gpu, y_gpu, test_size=0.2, random_state=42)print("GPU訓練中...")start_time = time.time()gpu_rf = RandomForestRegressor(n_estimators=100, max_depth=10, random_state=42)gpu_rf.fit(X_train_gpu, y_train_gpu)gpu_time = time.time() - start_time# 性能對比speedup = cpu_time / gpu_timeprint(f"\n性能對比:")print(f"CPU時間: {cpu_time:.2f} 秒")print(f"GPU時間: {gpu_time:.2f} 秒")print(f"加速比: {speedup:.2f}x")return speedup# 運行性能對比
speedup_ratio = compare_gpu_cpu_performance(featured_data)

6.2 不同數據規模的擴展性測試

def scalability_test(gpu_df, max_size=1000000, step=100000):"""測試不同數據規模下的性能"""results = []sizes = range(step, max_size + step, step)for size in sizes:print(f"測試數據規模: {size:,}")# 采樣數據sample_data = gpu_df.sample(n=min(size, len(gpu_df)), random_state=42)# GPU操作時間start_time = time.time()# 執行典型操作_ = sample_data.groupby('age_group').mean()  # 聚合操作_ = sample_data.sort_values('admission_date')  # 排序操作_ = sample_data.dropna()  # 清理操作gpu_time = time.time() - start_time# 轉換為Pandas進行CPU測試cpu_data = sample_data.to_pandas()start_time = time.time()# CPU相同操作_ = cpu_data.groupby('age_group').mean()_ = cpu_data.sort_values('admission_date')_ = cpu_data.dropna()cpu_time = time.time() - start_timespeedup = cpu_time / gpu_timeresults.append((size, cpu_time, gpu_time, speedup))print(f"  數據規模: {size:,}, CPU: {cpu_time:.2f}s, GPU: {gpu_time:.2f}s, 加速: {speedup:.2f}x")return results# 運行擴展性測試
scalability_results = scalability_test(featured_data)

7. 實際應用案例

7.1 患者分層分析

def patient_stratification_analysis(df, n_clusters=5):"""患者分層分析"""from cuml.cluster import KMeansfrom cuml.decomposition import PCAimport matplotlib.pyplot as plt# 選擇臨床特征進行聚類clinical_features = ['age', 'heart_rate', 'systolic_bp', 'temperature']if all(col in df.columns for col in clinical_features):# 提取特征X = df[clinical_features].dropna()# 標準化from cuml.preprocessing import StandardScalerscaler = StandardScaler()X_scaled = scaler.fit_transform(X)# K-means聚類kmeans = KMeans(n_clusters=n_clusters, random_state=42)clusters = kmeans.fit_predict(X_scaled)# 降維可視化pca = PCA(n_components=2)X_pca = pca.fit_transform(X_scaled)# 可視化(需要轉換為Pandas用于matplotlib)plt.figure(figsize=(10, 6))scatter = plt.scatter(X_pca.to_pandas().iloc[:, 0], X_pca.to_pandas().iloc[:, 1], c=clusters.to_pandas(), cmap='viridis', alpha=0.6)plt.colorbar(scatter)plt.title('患者分層可視化')plt.xlabel('PCA Component 1')plt.ylabel('PCA Component 2')plt.savefig('/data/patient_stratification.png', dpi=300, bbox_inches='tight')plt.close()# 分析各簇特征df['cluster'] = clusterscluster_stats = df.groupby('cluster')[clinical_features].mean()return cluster_statsreturn None# 執行患者分層分析
cluster_analysis = patient_stratification_analysis(featured_data)
print("患者分層統計:")
print(cluster_analysis)

7.2 疾病預測模型

def disease_prediction_pipeline(df, target_disease):"""疾病預測流水線"""# 創建目標變量df['has_disease'] = df['primary_diagnosis'].str.contains(target_disease, case=False).astype('int')# 準備特征feature_cols = ['age', 'gender', 'heart_rate', 'systolic_bp', 'temperature', 'bmi']X = df[feature_cols].dropna()y = df.loc[X.index, 'has_disease']# 劃分訓練測試集X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)# 訓練分類模型from cuml.linear_model import LogisticRegressionfrom cuml.metrics import accuracy_score, roc_auc_scoremodel = LogisticRegression()model.fit(X_train, y_train)# 預測和評估y_pred = model.predict(X_test)y_proba = model.predict_proba(X_test)[:, 1]accuracy = accuracy_score(y_test, y_pred)auc_score = roc_auc_score(y_test, y_proba)print(f"{target_disease} 預測模型:")print(f"準確率: {accuracy:.3f}")print(f"AUC: {auc_score:.3f}")return model, accuracy, auc_score# 運行疾病預測(示例:糖尿病預測)
diabetes_model, acc, auc = disease_prediction_pipeline(featured_data, 'diabetes')

8. 最佳實踐與優化建議

8.1 內存管理優化

def optimize_memory_usage(gpu_df):"""優化GPU內存使用"""# 調整數值類型for col in gpu_df.select_dtypes(include=['number']).columns:col_min = gpu_df[col].min()col_max = gpu_df[col].max()if col_min >= 0:if col_max < 255:gpu_df[col] = gpu_df[col].astype('uint8')elif col_max < 65535:gpu_df[col] = gpu_df[col].astype('uint16')elif col_max < 4294967295:gpu_df[col] = gpu_df[col].astype('uint32')else:if col_min > -128 and col_max < 127:gpu_df[col] = gpu_df[col].astype('int8')elif col_min > -32768 and col_max < 32767:gpu_df[col] = gpu_df[col].astype('int16')elif col_min > -2147483648 and col_max < 2147483647:gpu_df[col] = gpu_df[col].astype('int32')# 使用分類類型減少內存for col in gpu_df.select_dtypes(include=['object']).columns:if gpu_df[col].nunique() / len(gpu_df) < 0.5:  # 基數較低時gpu_df[col] = gpu_df[col].astype('category')return gpu_df# 優化內存使用
optimized_data = optimize_memory_usage(featured_data)
print(f"優化后內存使用: {optimized_data.memory_usage(deep=True).sum() / 1024**2:.2f} MB")

8.2 多GPU并行處理

對于超大規模數據集:

def multi_gpu_processing(df, num_gpus=2):"""多GPU并行處理"""from dask_cuda import LocalCUDAClusterfrom dask.distributed import Clientimport dask_cudf# 啟動Dask集群cluster = LocalCUDACluster(n_workers=num_gpus)client = Client(cluster)# 轉換為Dask cuDFdask_df = dask_cudf.from_cudf(df, npartitions=num_gpus * 4)# 分布式計算示例result = dask_df.groupby('age_group').mean().compute()# 關閉集群client.close()cluster.close()return result# 多GPU處理(如果有多個GPU)
if cp.cuda.runtime.getDeviceCount() > 1:multi_gpu_result = multi_gpu_processing(optimized_data)print("多GPU處理結果:", multi_gpu_result)

9. 總結與展望

9.1 性能提升總結

通過實際測試,GPU加速在臨床數據分析中表現出顯著優勢:

  • 數據加載:比Pandas快5-10倍
  • 數據清洗:比CPU操作快10-50倍
  • 機器學習:訓練時間減少到1/10到1/100
  • 內存效率:更好的內存管理和數據壓縮

9.2 應用前景

GPU加速的臨床數據分析具有廣闊的應用前景:

  1. 實時臨床決策支持:快速分析患者數據,提供實時治療建議
  2. 大規模流行病學研究:分析數百萬患者的疾病模式和風險因素
  3. 個性化醫療:基于患者特征快速生成個性化治療方案
  4. 醫療質量監控:實時監控醫療質量和患者安全指標

9.3 開始使用建議

對于想要開始使用GPU加速臨床數據分析的研究者:

  1. 從小開始:從中小規模數據集開始,逐步擴展到大規模數據
  2. 逐步遷移:先將最耗時的操作遷移到GPU,逐步完成全流程遷移
  3. 利用社區:RAPIDS社區活躍,遇到問題時可以尋求幫助
  4. 持續學習:GPU技術發展迅速,需要持續學習新技術和優化方法

GPU加速的臨床數據分析正在改變醫療研究的面貌,讓原本需要數天甚至數周的分析任務在數小時內完成。隨著技術的不斷成熟和硬件的持續發展,這種加速效應將更加明顯,為醫療健康領域帶來前所未有的研究效率和洞察力。


點擊AladdinEdu,同學們用得起的【H卡】算力平臺”,注冊即送-H卡級別算力80G大顯存按量計費靈活彈性頂級配置學生更享專屬優惠

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:
http://www.pswp.cn/pingmian/96277.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/96277.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/96277.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

二進制安裝MySQL 8.0指南:跨平臺、自定義數據路徑、安全遠程訪問配置

二進制安裝 MySQL 8.0 在生產或測試環境中&#xff0c;我們常常希望避免包管理器帶來的依賴和交互問題&#xff0c;尤其是當系統自帶版本過舊或安裝過程頻繁彈窗時。此時&#xff0c;使用 MySQL 官方提供的二進制壓縮包&#xff08;Generic Linux Binary&#xff09; 進行安裝…

Z檢驗與T檢驗的區別與聯系:原理、公式和案例全解

Z檢驗與T檢驗全解析&#xff1a;原理、區別與實際案例 統計學的核心任務之一&#xff0c;就是通過有限的樣本數據去推斷總體特征。在這一過程中&#xff0c;假設檢驗成為了最常見的工具。而在眾多檢驗方法中&#xff0c;Z檢驗與T檢驗幾乎是入門必學&#xff0c;也是應用最廣泛的…

SpringBoot之緩存(最詳細)

文章目錄項目準備新建項目并選擇模塊安裝添加依賴添加application.yml刪除demos.web包編寫pojo層userdto/ResultJson編寫mapper層UserMapper編寫service層UserService編寫controller層編寫配置類MybatisPlusConfig編寫測試類1 緩存分類1.1 MyBatis一級緩存1.2 MyBatis二級緩存1…

B站 韓順平 筆記 (Day 29)

目錄 1&#xff08;集合的框架體系&#xff09; 2&#xff08;Collection接口和常用方法&#xff09; 2.1&#xff08;Collection接口實現類特點&#xff09; 2.2&#xff08;常用方法&#xff09; 2.3&#xff08;遍歷元素方式1&#xff1a;迭代器&#xff09; 1&#x…

axios報錯解決:unsupported BodyInit type

目錄 問題 原因 解決方法 問題 Got ‘unsupported BodyInit type’ bug on iPhone 14(IOS 17.5) Issue #6444 axios/axios 我這里是iPhone 6plus打開會報錯白屏 好多人遇到了相同的問題 當我在 iPhone 14 上瀏覽頁面時,我收到一條錯誤消息:錯誤:不支持的 BodyInit 類型,…

iperf3網絡性能測試工具

iperf3 是一個功能非常強大的網絡性能測試工具,用于測量兩個網絡節點之間的最大TCP、UDP帶寬和性能。它通過創建數據流并測量其吞吐量來工作。 下面我將為您詳細介紹其核心用法、常用命令和參數。 核心概念:客戶端/服務器模式 iperf3 測試需要兩臺機器:一臺作為服務器端(…

【C#】 資源共享和實例管理:靜態類,Lazy<T>單例模式,IOC容器Singleton我們該如何選

文章目錄前言一、靜態類1.1 靜態類的特點1.2 靜態類的使用1.3 靜態類的缺點二、單例模式2.1 Lazy延遲初始化2.2 Lazy< T>單例模式的使用2.3 單例模式的特點三、IOC的Singleton總結前言 編寫程序的時候&#xff0c;常常能碰到當某些數據或方法需要被整個程序共享&#xf…

MySQL——存儲引擎、索引

一、存儲引擎1.MySQL體系結構2.存儲引擎簡介存儲引擎就是儲存數據、建立索引、更新/查詢數據等技術的實現方式。儲存引擎是基于表的&#xff0c;而不是基于庫的&#xff0c;所以存儲引擎也可被稱為表類型建表語句&#xff1a;查詢數據庫支持的儲存引擎&#xff1a;show engines…

機器學習01——機器學習概述

上一章&#xff1a;機器學習核心知識點目錄 下一章&#xff1a;機器學習02——模型評估與選擇 機器學習實戰項目&#xff1a;【從 0 到 1 落地】機器學習實操項目目錄&#xff1a;覆蓋入門到進階&#xff0c;大學生就業 / 競賽必備 文章目錄一、參考書推薦二、機器學習的基本概…

Shell編程:檢測主機ip所在網段內其他在線ip

一、邏輯設計獲取本機 ip 及 網段循環檢測網段內所有 ip判斷 ping 結果&#xff0c;符合條件的輸出相關信息二、代碼展示#!/bin/bash#獲取本機ip local_iphostname -I #local_ipip addr| grep "inet "|grep -v 127.0.0.1| awk {print $2}#獲取本機網段 networkecho $…

Windows安裝Chroma DB

安裝步驟 安裝python 3.8或以上的版本創建虛擬環境&#xff1a;python -m venv chroma_env激活虛擬環境&#xff1a;.\chroma_env\Scripts\activate安裝Chroma DB&#xff1a;pip install chromadb(可選)安裝擴展功能&#xff1a;pip install sentence-transformers pypdf tikt…

李彥宏親自說

昨天&#xff0c;李彥宏親自說&#xff1a;百度的數字人直播以假亂真&#xff0c;很多人是看不出這是數字人&#xff0c;而且轉化率很高”這幾個月百度一直在推“數字人”不再強調“大模型”了。數字人是AI落地最適合企業的一款產品&#xff0c;一般用于客服、面試、直播帶貨等…

JS 中bind、call、apply的區別以及手寫bind

1.作用call、apply、bind作用是改變函數執行的上下文&#xff0c;簡而言之就是改變函數運行時的this指向那么什么情況下需要改變this的指向呢&#xff1f;下面舉個例子var name "lucy"; var obj {name: "martin",say: function () {console.log(this.nam…

vue2(7)-單頁應用程序路由

1.單頁應用程序如 單頁&#xff1a;網易云&#xff0c;多頁&#xff1a;京東單頁應用程序&#xff0c;之所以開發效率高&#xff0c;性能高&#xff0c;用戶體驗好最大的原因是&#xff1a;頁面按需更新 要按需更新&#xff0c;就要明確訪問路徑和組件的關系這時候就要用…

vue中通過heatmap.js實現熱力圖(多個熱力點)熱區展示(帶鼠標移入彈窗)

直接上完整代碼&#xff01;記錄實現方式 注意heatmap.min.js需要通過heatmap.js提供的下載地址進行下載&#xff0c;地址放在下邊 url&#xff1a;heatmap GIT地址 <template><div class"heatmap-view" ref"heatmapContainer"></div&g…

配置Kronos:k線金融大模型

github地址 網頁btc預測demo使用的Kronos-mini模型 huggingface的倉庫 文章目錄配置環境安裝python環境獲取市場數據的庫通過webui使用example中的例子prediction_example.py補充說明根據原例優化的代碼CryptoDataFetcher單幣對多周期預測配置環境 使用conda的環境. 首先進行換…

【Deep Learning】Ubuntu配置深度學習環境

【start: 250715】 文章目錄ubuntu與深度學習安裝cuda查看顯卡信息&#xff08;nvidia-smi&#xff09;升級驅動下載cuda安裝conda安裝anaconda默認指向自己的conda初始化conda確認 conda.sh 被加載安裝cuda-toolkit直接安裝cuda-toolkit&#xff08;高級的&#xff09;安裝高于…

車載數據采集(DAQ)解析

<摘要> 車載數據采集&#xff08;DAQ&#xff09;軟件模塊是現代汽車電子系統的核心組件&#xff0c;負責實時采集、處理、記錄和傳輸車輛運行數據。本文系統解析了DAQ模塊的開發&#xff0c;涵蓋其隨著汽車智能化演進的歷史背景&#xff0c;深入闡釋了信號、協議、緩存等…

強化學習框架Verl運行在單塊Tesla P40 GPU配置策略及避坑指南

1.前言 由于比較窮,身邊只有1塊10年前的Tesla P40 GPU卡(2016年9月發布),想利用起來學習強化學習框架Verl。程序員學習開源代碼,大部分人的第一直覺不是分析模塊組成,而是跑起來試試,然后去debug一下后面的運行邏輯。 由于在官方部署指導文檔中并未指明跑通Verl的最低…

leetcode169.多數元素

題目描述給定一個大小為 n 的數組 nums &#xff0c;返回其中的多數元素。多數元素是指在數組中出現次數 大于 ? n/2 ? 的元素。你可以假設數組是非空的&#xff0c;并且給定的數組總是存在多數元素。題目解法博耶-摩爾多數投票算法&#xff08;英語&#xff1a;Boyer–Moore…