### Install changeforest using Conda Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Installs the changeforest package from the conda-forge channel, which is the recommended installation method for users with Conda environments. ```bash conda install -c conda-forge changeforest ``` -------------------------------- ### Import changeforest in R Session Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/Installing_R_packages_with_conda.md Starts an interactive R session and loads the installed `changeforest` library. This verifies the successful installation and availability of the package. ```R (R) ~ $ R R version 4.1.3 (2022-03-10) -- "One Push-Up" ... > library(changeforest) ``` -------------------------------- ### Install Changeforest with Conda Source: https://github.com/mlondschien/changeforest/blob/main/README.md Installs the changeforest Python package using the conda-forge channel. This is the recommended installation method for users who prefer or already use the Conda package manager. ```bash conda install -c conda-forge changeforest ``` -------------------------------- ### Install r-changeforest via Conda Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Installs the r-changeforest package from the conda-forge channel. Requires conda to be installed. ```bash conda install -c conda-forge r-changeforest ``` -------------------------------- ### Install changeforest using Pip Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Installs the changeforest package from the Python Package Index (PyPI) using pip, suitable for users managing Python environments with pip. ```bash pip install changeforest ``` -------------------------------- ### Install R Package MASS with Conda Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/Installing_R_packages_with_conda.md Example command to install another R package, `r-mass`, from the `conda-forge` channel. This demonstrates the pattern for installing other R packages. ```Bash (R) ~ $ conda install -c conda-forge -y r-mass ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/Installing_R_packages_with_conda.md Creates a new Conda environment named 'R' and activates it for package installations. This isolates R dependencies and ensures a clean setup. ```Bash (base) ~ $ conda create --name R (base) ~ $ conda activate R (R) ~ $ ``` -------------------------------- ### Install Changeforest with Pip Source: https://github.com/mlondschien/changeforest/blob/main/README.md Installs the changeforest Python package from PyPI using pip. This method is suitable for users who manage their Python environments with pip. ```bash pip install changeforest ``` -------------------------------- ### Install R changeforest Package with Conda Source: https://github.com/mlondschien/changeforest/blob/main/README.md Provides the command to install the r-changeforest package from the conda-forge channel. This is the recommended method for installing the changeforest library for use within the R environment. ```bash conda install -c conda-forge r-changeforest ``` -------------------------------- ### Install R Base and changeforest with Conda Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/Installing_R_packages_with_conda.md Installs the R base package and the changeforest R package from the conda-forge channel. The `-y` flag confirms installations automatically. ```Bash (R) ~ $ conda install -c conda-forge -y r-base r-changeforest ``` -------------------------------- ### Tune Change Point Detection with Control Parameters Source: https://github.com/mlondschien/changeforest/blob/main/README.md Demonstrates how to tune the changeforest algorithm by passing a Control object. This example sets the number of trees for the random forest to 20, which can lead to false positives. ```R changeforest(X, "random_forest", "bs", Control$new(random_forest_n_estimators=20)) ``` -------------------------------- ### Tune Random Forest with Control Parameters Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Demonstrates how to tune the changeforest algorithm by passing a Control object. This example sets the number of trees for the random forest to 20, potentially affecting detection accuracy. ```R changeforest(X, "random_forest", "bs", Control$new(random_forest_n_estimators=20)) ``` -------------------------------- ### Simulate Multivariate Gaussian Data Source: https://github.com/mlondschien/changeforest/blob/main/README.md Simulates a dataset with covariance shifts using the MASS package. This setup is used to test change point detection algorithms in challenging scenarios. ```R library(MASS) set.seed(0) Sigma = matrix(0.7, nrow=5, ncol=5) diag(Sigma) = 1 mu = rep(0, 5) X = rbind( mvrnorm(n=200, mu=mu, Sigma=diag(5)), mvrnorm(n=200, mu=mu, Sigma=Sigma), mvrnorm(n=200, mu=mu, Sigma=diag(5)) ) ``` -------------------------------- ### Simulate Data for Change Point Detection Source: https://github.com/mlondschien/changeforest/blob/main/README.md Demonstrates generating a dataset with covariance shifts using NumPy for change point detection experiments. This setup simulates a challenging scenario with correlated data segments. ```python import numpy as np Sigma = np.full((5, 5), 0.7) np.fill_diagonal(Sigma, 1) rng = np.random.default_rng(12) X = np.concatenate( ( rng.normal(0, 1, (200, 5)), rng.multivariate_normal(np.zeros(5), Sigma, 200, method="cholesky"), rng.normal(0, 1, (200, 5)), ), axis=0, ) ``` -------------------------------- ### Simulate Dataset with Covariance Shifts Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Generates a simulated dataset with 600 observations and covariance shifts at specific points (t=200, 400). This setup is used to test change point detection algorithms. ```R library(MASS) set.seed(0) Sigma = matrix(0.7, nrow=5, ncol=5) diag(Sigma) = 1 mu = rep(0, 5) X = rbind( mvrnorm(n=200, mu=mu, Sigma=diag(5)), mvrnorm(n=200, mu=mu, Sigma=Sigma), mvrnorm(n=200, mu=mu, Sigma=diag(5)) ) ``` -------------------------------- ### Change Point Detection with Change in Mean Method Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Illustrates the use of the 'change_in_mean' method for change point detection. This example shows a scenario where this method fails to detect any change points due to the nature of the simulated data. ```R changeforest(X, "change_in_mean", "bs") ``` -------------------------------- ### Change Point Detection with Change in Mean Method Source: https://github.com/mlondschien/changeforest/blob/main/README.md Shows the changeforest function applied with the "change_in_mean" method. This example illustrates a scenario where this method is unable to detect change points due to the nature of the simulated data. ```python changeforest(X, "change_in_mean", "bs") ``` -------------------------------- ### Tune Changeforest with Control Parameters Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Demonstrates tuning the changeforest algorithm by passing a Control object with custom hyperparameters, such as setting the number of trees for the random forest. ```python from changeforest import Control changeforest(X, "random_forest", "bs", Control(random_forest_n_estimators=50)) ``` -------------------------------- ### Tune Changeforest with Control Parameters Source: https://github.com/mlondschien/changeforest/blob/main/README.md Demonstrates how to tune the changeforest algorithm by passing a Control object with specific hyperparameters, such as setting the number of trees for the random forest. This allows for customization of the detection process. ```python from changeforest import Control changeforest(X, "random_forest", "bs", Control(random_forest_n_estimators=50)) ``` -------------------------------- ### Visualize Optimizer Results Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Shows the gain curves from the optimizer, highlighting initial guesses (blue) and maxima, for the changeforest algorithm. This helps investigate the gain curves maximized by the change point estimates. ```python result.optimizer_result.plot().show() ``` -------------------------------- ### Visualize Optimizer Gain Curves Source: https://github.com/mlondschien/changeforest/blob/main/README.md Plots the gain curves from the optimizer result, showing piecewise linear approximations and initial guesses (marked in blue) used by the random forest and KNN methods. ```R plot(result$optimizer_result) ``` -------------------------------- ### Simulate Dataset with NumPy Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Generates a simulated dataset with covariance shifts using NumPy for change point detection experiments. The dataset consists of 600 observations with covariance changes at t=200 and t=400. ```python import numpy as np Sigma = np.full((5, 5), 0.7) np.fill_diagonal(Sigma, 1) rng = np.random.default_rng(12) X = np.concatenate( ( rng.normal(0, 1, (200, 5)), rng.multivariate_normal(np.zeros(5), Sigma, 200, method="cholesky"), rng.normal(0, 1, (200, 5)), ), axis=0, ) ``` -------------------------------- ### Basic Change Point Detection with Random Forest Source: https://github.com/mlondschien/changeforest/blob/main/README.md Applies the changeforest function using the 'random_forest' method and 'bs' (binary segmentation) approach. It displays the detected change points and their significance. ```R library(changeforest) result = changeforest(X, "random_forest", "bs") print(result) # Retrieve identified split points print(result$split_points()) ``` -------------------------------- ### Perform Change Point Detection with Random Forest Source: https://github.com/mlondschien/changeforest/blob/main/README.md Applies the changeforest function with the "random_forest" method and "bs" (binary segmentation) algorithm. It shows the resulting BinarySegmentationResult and how to access its split points. ```python from changeforest import changeforest result = changeforest(X, "random_forest", "bs") print(result) print(result.split_points()) ``` -------------------------------- ### Perform Change Point Detection with changeforest Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Applies the changeforest algorithm to detect change points in the simulated dataset using a random forest method ('random_forest') with binary segmentation ('bs'). ```python from changeforest import changeforest result = changeforest(X, "random_forest", "bs") result ``` -------------------------------- ### Visualize Optimizer Gain Curves Source: https://github.com/mlondschien/changeforest/blob/main/README.md Visualizes the gain curves generated by the optimizer result within the changeforest algorithm. This plot highlights initial guesses (blue) and the approximate gain curves (piecewise linear) used to find the optimal split. ```python result.optimizer_result.plot().show() ``` -------------------------------- ### Visualize Change Point Detection Results Source: https://github.com/mlondschien/changeforest/blob/main/README.md Uses the plot method of the BinarySegmentationResult to visualize gain curves and mark the estimated change points. This helps in understanding the algorithm's output and the detected change locations. ```python result.plot().show() ``` -------------------------------- ### Perform Change Point Detection with Random Forest Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Applies the changeforest function using the 'random_forest' method and 'bs' (binary segmentation) approach. It then displays the detected change points and their significance. ```R library(changeforest) result = changeforest(X, "random_forest", "bs") result result$split_points() ``` -------------------------------- ### Visualize Changeforest Results Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Displays the gain curves and detected change points using the plot method of the BinarySegmentationResult object. Change point estimates are marked in red. ```python result.plot().show() ``` -------------------------------- ### Plot Changeforest Results Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Visualizes the output of the changeforest function by plotting the gain curves associated with the detected change points. This helps in understanding the algorithm's decision process. ```R plot(result) ``` -------------------------------- ### Visualize Change Point Detection Results Source: https://github.com/mlondschien/changeforest/blob/main/README.md Generates a plot of the change forest results, highlighting the estimated change points (marked in red) on the gain curves. ```R plot(result) ``` -------------------------------- ### Plot Optimizer Results Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-r/README.md Displays the gain curves generated by the optimizer used in the random forest and KNN methods. These curves, marked with initial guesses, show piecewise linear approximations of the gain. ```R plot(result$optimizer_result) ``` -------------------------------- ### Change Point Detection with Change in Mean Method Source: https://github.com/mlondschien/changeforest/blob/main/README.md Illustrates the behavior of the changeforest function when using the 'change_in_mean' method on data with covariance shifts, showing its inability to detect such changes. ```R changeforest(X, "change_in_mean", "bs") ``` -------------------------------- ### Change Point Detection with Change in Mean Method Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Applies the changeforest algorithm using the 'change_in_mean' method to detect change points. This method is shown to be unable to detect changes in the given dataset. ```python changeforest(X, "change_in_mean", "bs") ``` -------------------------------- ### Extract Split Points from Changeforest Result Source: https://github.com/mlondschien/changeforest/blob/main/changeforest-py/README.md Retrieves the detected change point locations from the BinarySegmentationResult object returned by the changeforest function. ```python result.split_points() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.