### Quick Start with GeoDetector Source: https://github.com/djw-easy/geodetector/blob/main/README.md Demonstrates loading example data and initializing the GeoDetector. Automatically detects discrete columns as factors if 'factors' is not provided. ```python from geodetector import load_example_data, GeoDetector # Load example disease dataset df = load_example_data() # Initialize: Automatically detects discrete columns as factors if 'factors' is not provided gd = GeoDetector(df, y='incidence') print(f"Detected factors: {gd.factors}") ``` -------------------------------- ### Load Example Data Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Load a sample dataset for demonstration purposes. ```python df = load_example_data() df.head() ``` -------------------------------- ### Install py-geodetector Source: https://github.com/djw-easy/geodetector/blob/main/README.md Install the py-geodetector package using pip. ```bash pip install py-geodetector ``` -------------------------------- ### Factor Detector Usage Source: https://github.com/djw-easy/geodetector/blob/main/README.md Shows how to perform batch detection for all factors or single factor detection, returning q-value and p-value. ```python # 1. Factor Detector # Batch detection for all factors factor_df = gd.factor_detector() # Single factor detection: returns (q_value, p_value) q, p = gd.factor_detector('type') ``` -------------------------------- ### Interaction Detector Usage Source: https://github.com/djw-easy/geodetector/blob/main/README.md Demonstrates calculating the full interaction matrix or pairwise detection with relationship descriptions. ```python # 2. Interaction Detector # Full matrix calculation interaction_df = gd.interaction_detector() # Pairwise detection with relationship description q_inter, relationship = gd.interaction_detector('type', 'region', relationship=True) ``` -------------------------------- ### Import GeoDetector Library Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Import necessary functions from the geodetector library. ```python from geodetector import load_example_data, GeoDetector ``` -------------------------------- ### Initialize GeoDetector Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Initialize the GeoDetector with a DataFrame and the dependent variable. ```python gd = GeoDetector(df, 'incidence') print(f"Detected factors: {gd.factors}") ``` -------------------------------- ### Perform Risk Detection Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Perform risk detection analysis for all factors. ```python risk_result = gd.risk_detector() ``` -------------------------------- ### Risk Detector Usage Source: https://github.com/djw-easy/geodetector/blob/main/README.md Demonstrates using the Risk Detector to compare average Y between sub-groups of a factor and prints the mean values for each stratum. ```python # 4. Risk Detector # Compare average Y between sub-groups of a factor risk_result = gd.risk_detector('type') print(risk_result['risk']) # Mean values for each stratum ``` -------------------------------- ### Ecological Detector Usage Source: https://github.com/djw-easy/geodetector/blob/main/README.md Shows how to use the Ecological Detector to determine if the impact of two factors are significantly different. ```python # 3. Ecological Detector # Determine if the impact of two factors are significantly different eco_df = gd.ecological_detector() ``` -------------------------------- ### Visualization with Plot Method Source: https://github.com/djw-easy/geodetector/blob/main/README.md Generates an interaction heatmap with statistical significance markers. Red markers indicate significant ecological difference. ```python # 5. Visualization # Plot interaction heatmap (red markers indicate significant ecological difference) gd.plot(factors=['type', 'region', 'level']) ``` -------------------------------- ### Factor Detection for Multiple Factors Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Perform factor detection for a list of specified factors. ```python gd.factor_detector(['type', 'region']) ``` -------------------------------- ### Perform Interaction Detection Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect interactions between all pairs of factors. ```python gd.interaction_detector() ``` -------------------------------- ### Risk Detection for a Specific Factor Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Perform risk detection and access the 'risk' results for a specific factor. ```python gd.risk_detector('type')['risk'] ``` -------------------------------- ### Ecological Detection for All Factors Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect ecological interactions among all specified factors. ```python gd.ecological_detector(factors=['region', 'type', 'level']) ``` -------------------------------- ### Interaction Detection for Specific Factors Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect interactions between a specified subset of factors. ```python gd.interaction_detector(factors=['type', 'region']) ``` -------------------------------- ### Plot GeoDetector Results for Specific Factors Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Generate a plot of the GeoDetector results for a specified subset of factors. ```python gd.plot(factors=['type', 'region']); ``` -------------------------------- ### Interaction Detection with Relationship Type Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect interactions between factors and identify the type of relationship. ```python gd.interaction_detector(relationship=True)[1] ``` -------------------------------- ### Access Risk Detection Results for a Factor Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Access the 'risk' component of the risk detection results for a specific factor. ```python risk_result['type']['risk'] ``` -------------------------------- ### Factor Detection for a Specific Factor Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Perform factor detection for a single specified factor. ```python q, p = gd.factor_detector('type') q, p ``` -------------------------------- ### Ecological Detection for Specific Factors (Region vs Type) Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect the ecological interaction between 'region' and 'type'. ```python gd.ecological_detector('region', 'type') ``` -------------------------------- ### Ecological Detection for Specific Factors (Type vs Region) Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect the ecological interaction between 'type' and 'region'. ```python gd.ecological_detector('type', 'region') ``` -------------------------------- ### Plot GeoDetector Results Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Generate a plot of the GeoDetector results with custom font sizes. ```python gd.plot(value_fontsize=14, tick_fontsize=16, colorbar_fontsize=14); ``` -------------------------------- ### Interaction Detection for Two Specific Factors Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect the interaction effect between two specific factors. ```python gd.interaction_detector('type', 'region') ``` -------------------------------- ### Interaction Detection for Two Factors with Relationship Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect the interaction effect between two specific factors and its relationship type. ```python gd.interaction_detector('type', 'region', relationship=True) ``` -------------------------------- ### Perform Ecological Detection Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect the ecological interaction between factors. ```python gd.ecological_detector() ``` -------------------------------- ### Ecological Detection for Multiple Factors Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect ecological interactions among a specified list of factors. ```python gd.ecological_detector(factors=['type', 'region']) ``` -------------------------------- ### Perform Factor Detection Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Detect the influence of all factors on the dependent variable. ```python gd.factor_detector() ``` -------------------------------- ### Access T-test Results from Risk Detection Source: https://github.com/djw-easy/geodetector/blob/main/example.ipynb Access the 'ttest_stra' component of the risk detection results, showing t-test comparisons between factor levels. ```python risk_result['type']['ttest_stra'] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.