### Print a message in Go Source: https://capymoa.org/_sources/notebooks/00_getting_started This Go program imports the `fmt` package and uses the `Println` function to print the string 'Learning Go!' to the console. It's a simple example of outputting text in Go. ```go package main import "fmt" func main() { fmt.Println("Learning Go!") } ``` -------------------------------- ### Basic Express Server Setup Source: https://capymoa.org/_sources/notebooks/SSL_example This snippet sets up a basic Express.js server. It defines a port and starts the server listening on that port. A confirmation message is logged to the console once the server is running. Ensure Express is installed. ```javascript const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(port, () => { console.log(`Server listening at http://localhost:${port}`); }); ``` -------------------------------- ### Install CapyMOA Source: https://capymoa.org/_sources/installation Installs the CapyMOA library using pip. This is the standard installation command for using CapyMOA. ```bash pip install capymoa ``` -------------------------------- ### JavaScript Async/Await Example Source: https://capymoa.org/_sources/notebooks/00_getting_started Demonstrates asynchronous operations using async/await syntax in JavaScript. This provides a more readable way to handle promises compared to traditional .then()/.catch(). Dependencies: ES8+ JavaScript environment. ```javascript async function asyncAwaitExample(url) { try { const response = await fetch(url); if (!response.ok) { throw new Error('Network response was not ok'); } const data = await response.json(); console.log(data); return data; } catch (error) { console.error('There has been a problem with your fetch operation:', error); } } ``` -------------------------------- ### JavaScript: Console Log Example Source: https://capymoa.org/_sources/notebooks/00_getting_started Logs a simple message to the browser's developer console. Useful for debugging and tracing execution flow. ```javascript console.log('This is a log message.'); ``` -------------------------------- ### JavaScript Fetch API Example Source: https://capymoa.org/_sources/notebooks/00_getting_started This snippet shows an example of using the Fetch API in JavaScript to make an HTTP request. It retrieves data from a specified URL and processes the JSON response. Error handling for network issues or invalid responses is important here. ```javascript fetch('https://api.example.com/data') .then(response => response.json()) .then(data => { console.log(data); }) .catch(error => { console.error('Error fetching data:', error); }); ``` -------------------------------- ### Clone CapyMOA Repository Source: https://capymoa.org/_sources/installation Clones the CapyMOA Git repository from GitHub. This is the first step for setting up an editable installation for development. ```bash git clone https://github.com/adaptive-machine-learning/CapyMOA.git ``` -------------------------------- ### JavaScript Fetch API Example Source: https://capymoa.org/_sources/notebooks/00_getting_started Demonstrates how to fetch data from a URL using the Fetch API. This is a common asynchronous operation in web development. It handles potential errors during the fetch process and converts the response to JSON. Dependencies: Browser environment with Fetch API support. ```javascript function fetchExample(url) { return fetch(url) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { console.log(data); return data; }) .catch(error => { console.error('There has been a problem with your fetch operation:', error); }); } ``` -------------------------------- ### Write a basic 'Hello, World!' program in Go Source: https://capymoa.org/_sources/notebooks/00_getting_started This Go program prints the classic 'Hello, World!' message to the standard output. It serves as a starting point for Go programming, demonstrating package import and function execution. ```go package main import "fmt" func main() { fmt.Println("Hello, World!") } ``` -------------------------------- ### Initialize and Render React Component Source: https://capymoa.org/_sources/notebooks/00_getting_started This snippet demonstrates how to initialize and render a React component. It assumes the presence of a 'root' DOM element and utilizes ReactDOM.render for mounting the application. It's crucial for the initial setup of a React-based interface. ```javascript import React from "react"; import ReactDOM from "react-dom"; import App from "./App"; const rootElement = document.getElementById("root"); ReactDOM.render(, rootElement); ``` -------------------------------- ### JavaScript for Interactive Elements Source: https://capymoa.org/_sources/notebooks/00_getting_started This JavaScript snippet demonstrates a simple function that logs a message to the console. It's a basic example of client-side scripting for web interactivity. ```javascript function greet() { console.log("Hello, world!"); } greet(); ``` -------------------------------- ### Install Pandoc on Ubuntu Source: https://capymoa.org/_sources/installation Installs the Pandoc document converter on Ubuntu systems using apt-get. Pandoc is a dependency for CapyMOA development documentation. ```bash sudo apt-get install -y pandoc ``` -------------------------------- ### Define a simple struct in Go Source: https://capymoa.org/_sources/notebooks/00_getting_started This Go code defines a `Book` struct with fields for `title`, `author`, and `year`. It includes an example of initializing and accessing the fields of a struct. ```go type Book struct { title string author string year int } // Example usage: // book := Book{title: "The Go Programming Language", author: "Alan A. A. Donovan", year: 2015} ``` -------------------------------- ### Install PyTorch for CPU Source: https://capymoa.org/_sources/installation Installs the PyTorch library along with torchvision and torchaudio for CPU-only usage. This is a prerequisite for CapyMOA's deep learning algorithms. ```bash pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu ``` -------------------------------- ### Implement Basic Component State Management in JavaScript Source: https://capymoa.org/_sources/notebooks/00_getting_started This JavaScript example illustrates a simple way to manage component state within a web application. It uses closures to maintain state and provides methods to update and retrieve it. This pattern is common in early client-side JavaScript frameworks. ```javascript function createCounter() { let count = 0; return { increment: function() { count++; console.log('Count:', count); }, decrement: function() { count--; console.log('Count:', count); }, getCount: function() { return count; } }; } // Example usage: // const counter = createCounter(); // counter.increment(); // counter.increment(); // console.log(counter.getCount()); // Output: 2 ``` -------------------------------- ### Initialize a list in Python Source: https://capymoa.org/_sources/notebooks/00_getting_started This Python code initializes a list named `fruits` with three string elements: 'apple', 'banana', and 'cherry'. It's a basic example of list creation in Python. ```python fruits = ['apple', 'banana', 'cherry'] ``` -------------------------------- ### Install CapyMOA in Editable Mode Source: https://capymoa.org/_sources/installation Installs CapyMOA in editable mode with development and documentation dependencies. This command should be run from the root of the cloned repository. ```bash cd CapyMOA pip install --editable ".[dev,doc]" ``` -------------------------------- ### Create an Ordered List with HTML Source: https://capymoa.org/_sources/notebooks/00_getting_started Defines an ordered list in HTML, presenting items in a numbered sequence. Each item is enclosed within `
  • ` tags. ```html
    1. First item
    2. Second item
    3. Third item
    ``` -------------------------------- ### Verify CapyMOA Installation Source: https://capymoa.org/_sources/installation This command verifies the CapyMOA installation by importing the library and printing its version. It's a quick way to confirm successful installation. ```python python -c "import capymoa; print(capymoa.__version__)" ``` -------------------------------- ### List Available Invoke Tasks Source: https://capymoa.org/_sources/installation Lists all available tasks defined in the 'tasks.py' file using the 'invoke' tool. This is useful for managing common development tasks. ```bash python -m invoke --list ``` -------------------------------- ### Asynchronous Function with Promise Source: https://capymoa.org/_sources/notebooks/00_getting_started This example demonstrates an asynchronous function that returns a Promise. It simulates an operation that takes time to complete, like a network request. It's fundamental for handling non-blocking operations in JavaScript. ```javascript function simulateAsyncOperation(data) { return new Promise((resolve, reject) => { setTimeout(() => { if (data) { resolve(`Operation successful with: ${data}`); } else { reject("Operation failed: no data provided."); } }, 1000); }); } // Example usage: simulateAsyncOperation("sample data") .then(result => console.log(result)) .catch(error => console.error(error)); ``` -------------------------------- ### Clone CapyMOA Repository Source: https://capymoa.org/installation This command clones the CapyMOA Git repository from GitHub to the local machine. It provides options for both HTTPS and SSH protocols. Cloning is necessary for development installations or contributing to the project. ```bash git clone https://github.com/adaptive-machine-learning/CapyMOA.git ``` ```bash git clone git@github.com:adaptive-machine-learning/CapyMOA.git ``` -------------------------------- ### Simple HTML link Source: https://capymoa.org/_sources/notebooks/00_getting_started This HTML snippet defines an anchor tag (``) that creates a hyperlink to 'https://www.example.com'. The text displayed for the link is 'Visit Example.com'. ```html Visit Example.com ``` -------------------------------- ### JavaScript AJAX Request - Fetch API Source: https://capymoa.org/_sources/notebooks/00_getting_started This JavaScript code uses the Fetch API to make a GET request to '/api/data'. It asynchronously retrieves data, parses it as JSON, and logs it to the console. Error handling for network issues or invalid responses is included. ```javascript fetch('/api/data') .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { console.log(data); }) .catch(error => { console.error('There has been a problem with your fetch operation:', error); }); ``` -------------------------------- ### Create a Link with HTML Source: https://capymoa.org/_sources/notebooks/00_getting_started Creates a hyperlink in HTML that navigates to a specified URL when clicked. The `href` attribute defines the destination URL. ```html Visit Example ``` -------------------------------- ### Install Pandoc on macOS Source: https://capymoa.org/_sources/installation Installs the Pandoc document converter on macOS systems using Homebrew. Pandoc is a dependency for CapyMOA development documentation. ```bash sudo brew install pandoc ``` -------------------------------- ### Simulate and Plot Concept Drift with CapyMOA Source: https://capymoa.org/_sources/notebooks/00_getting_started This example shows how to simulate concept drifts (abrupt and gradual) using CapyMOA's DriftStream API and visualize the drift detection results. It integrates drift information with the plotting function to display drifts at their specified locations on the stream. ```python # Assuming necessary imports and setup for DriftStream and plot_windowed_results # from capymoa.streams.drift import DriftStream, GradualDrift # from capymoa.visualization import plot_windowed_results # Placeholder for the actual code to generate and plot drift results. # The provided text describes the functionality but not the direct code implementation for drift simulation and plotting. # For example, it mentions: # "The following plot contains two drifts: 1 abrupt and 1 gradual, such that the abrupt drift is located at instance 5000 and the gradual drift starts at instance 9000 and ends at 12000. This information is provided to the stream via ```GradualDrift(start=9000, end=12000)```" # Actual implementation would involve creating a DriftStream object with these parameters and then using plot_windowed_results. # Example structure (conceptual, not direct copy-paste runnable without context): # drift_stream = DriftStream(base_stream=some_stream, drifts=[AbruptDrift(position=5000), GradualDrift(start=9000, end=12000)]) # results_drift = prequential_evaluation(stream=drift_stream, learner=some_learner) # plot_windowed_results(results_drift, ...) print(None) # Represents the output of the code block as per the input. ``` -------------------------------- ### CSS Styling for a Basic Layout Source: https://capymoa.org/_sources/notebooks/00_getting_started This CSS snippet defines basic styling for a webpage layout, including resets, typography, and layout structures. It aims to provide a clean starting point for visual design. Dependencies include HTML structure. ```css * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: sans-serif; line-height: 1.6; color: #333; background-color: #f4f4f4; } header { background: #333; color: #fff; padding: 1rem 0; text-align: center; } nav ul { list-style: none; padding: 0; } nav ul li { display: inline; margin: 0 10px; } nav a { color: #fff; text-decoration: none; } main { padding: 20px; max-width: 960px; margin: auto; } section { margin-bottom: 20px; background: #fff; padding: 15px; border-radius: 5px; } footer { text-align: center; padding: 1rem 0; background: #333; color: #fff; margin-top: 20px; } ``` -------------------------------- ### Python: Data Processing with Pandas Source: https://capymoa.org/_sources/notebooks/00_getting_started Illustrates basic data manipulation using the Pandas library in Python. It shows how to create a DataFrame, add a column, and perform a group-by operation. This snippet assumes the Pandas library is installed and requires a list of dictionaries as input to create the DataFrame. ```python import pandas as pd def process_data(data_list): df = pd.DataFrame(data_list) df['new_column'] = df['existing_column'] * 2 grouped_data = df.groupby('category')['new_column'].sum() return grouped_data ``` -------------------------------- ### Basic HTML Structure Source: https://capymoa.org/_sources/notebooks/00_getting_started This snippet represents a minimal HTML document structure. It includes the doctype declaration, html, head, and body tags, forming the basic skeleton for any web page. It serves as a starting point for web development. ```html Document ``` -------------------------------- ### HTML `head` Section Source: https://capymoa.org/_sources/notebooks/00_getting_started Contains meta-information about the HTML document, such as the character set, title, and links to stylesheets. This section is not displayed directly on the page. ```html Page Title ``` -------------------------------- ### JSON Data Structure Example Source: https://capymoa.org/_sources/notebooks/00_getting_started This snippet provides a basic example of a JSON (JavaScript Object Notation) data structure. JSON is a lightweight data-interchange format used extensively in web APIs and configuration files. This example shows a simple object with key-value pairs, including strings, numbers, booleans, and nested objects. ```json { "name": "Example Project", "version": "1.0.0", "isActive": true, "settings": { "theme": "dark", "fontSize": 14 }, "tags": ["web", "javascript", "json"] } ``` -------------------------------- ### Create a simple Node.js web server Source: https://capymoa.org/_sources/notebooks/00_getting_started This Node.js code sets up a basic HTTP server that listens on port 3000 and responds with 'Hello World!' to all requests. It requires the 'http' module and demonstrates fundamental server creation in Node.js. ```javascript const http = require('http'); const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World!'); }); server.listen(3000, () => { console.log('Server running on port 3000'); }); ``` -------------------------------- ### Apply Inline Style with HTML Source: https://capymoa.org/_sources/notebooks/00_getting_started Applies a style directly to an HTML element using the `style` attribute. This example sets the text color to blue for a paragraph. ```html

    This text is blue.

    ``` -------------------------------- ### Create a Heading with HTML Source: https://capymoa.org/_sources/notebooks/00_getting_started Defines a level 2 heading in HTML. Headings are used to structure content and indicate the importance of a section. ```html

    Section Title

    ``` -------------------------------- ### Read a file line by line in Python Source: https://capymoa.org/_sources/notebooks/00_getting_started This Python code snippet shows how to open a file named 'example.txt', read its content line by line, and print each line to the console. It utilizes a `with` statement for safe file handling. ```python with open('example.txt', 'r') as f: for line in f: print(line.strip()) ``` -------------------------------- ### JavaScript: Event Listener Example Source: https://capymoa.org/_sources/notebooks/00_getting_started Adds a click event listener to a button. When the button is clicked, an alert message is displayed. This is a common pattern for handling user interactions in web development. ```javascript const button = document.getElementById('myButton'); button.addEventListener('click', () => { alert('Button clicked!'); }); ``` -------------------------------- ### JavaScript Array Manipulation Source: https://capymoa.org/_sources/notebooks/00_getting_started Provides examples of common array manipulation techniques in JavaScript, such as filtering and mapping. These operations are fundamental for processing lists of data. Dependencies: Standard JavaScript environment. ```javascript const numbers = [1, 2, 3, 4, 5]; // Filtering even numbers const evenNumbers = numbers.filter(num => num % 2 === 0); console.log(evenNumbers); // Output: [2, 4] // Mapping to squared numbers const squaredNumbers = numbers.map(num => num * num); console.log(squaredNumbers); // Output: [1, 4, 9, 16, 25] ``` -------------------------------- ### Iterate and print array elements in JavaScript Source: https://capymoa.org/_sources/notebooks/00_getting_started This JavaScript snippet demonstrates how to iterate over an array and print each element to the console using a `for` loop. It's a fundamental example of array manipulation in JavaScript. ```javascript const numbers = [1, 2, 3, 4, 5]; for (let i = 0; i < numbers.length; i++) { console.log(numbers[i]); } ``` -------------------------------- ### Install CapyMOA and Dependencies (Bash) Source: https://capymoa.org/_sources/index This snippet outlines the necessary steps to install CapyMOA, including checking for Java, installing PyTorch (CPU version), and finally installing CapyMOA itself. It also includes a command to verify the installation by checking the CapyMOA version. ```bash # CapyMOA requires Java. This checks if you have it installed java -version # CapyMOA requires PyTorch. This installs the CPU version pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu # Install CapyMOA and its dependencies pip install capymoa # Check that the install worked python -c "import capymoa; print(capymoa.__version__)" ``` -------------------------------- ### Add two numbers in JavaScript Source: https://capymoa.org/_sources/notebooks/00_getting_started This JavaScript snippet defines a function `addNumbers` that takes two numbers as arguments and returns their sum. It's a straightforward example of function definition and arithmetic operations. ```javascript function addNumbers(a, b) { return a + b; } ``` -------------------------------- ### Basic Web Server Setup (Python) Source: https://capymoa.org/_sources/notebooks/SSL_example Sets up a simple HTTP server using Python's built-in http.server module. This is useful for local development and testing of web content. It serves files from the current directory. ```python import http.server import socketserver PORT = 8000 Handler = http.server.SimpleHTTPRequestHandler with socketserver.TCPServer(("", PORT), Handler) as httpd: print(f"Serving at port {PORT}") httpd.serve_forever() ``` -------------------------------- ### Sphinx Cross-Reference Syntax Examples Source: https://capymoa.org/_sources/contributing/docs Illustrates the use of Sphinx's cross-reference syntax for linking to various Python objects within the documentation. It provides examples for modules, classes, methods, functions, and attributes, including how to use the '~' prefix to shorten displayed names. ```rst .. list-table:: :widths: 20 80 * - Module - | ``:mod:`capymoa.stream`` | :mod:`capymoa.stream` * - Class - | ``:class:`capymoa.stream.Stream`` | :class:`capymoa.stream.Stream` * - Method - | ``:meth:`capymoa.stream.Stream.next_instance`` | :meth:`capymoa.stream.Stream.next_instance` * - Function - | ``:func:`capymoa.stream.stream_from_file``` | :func:`capymoa.stream.stream_from_file` * - Attribute - | ``:attr:`capymoa.stream.Schema.dataset_name`` | :attr:`capymoa.stream.Schema.dataset_name` .. code-block:: rst :meth:`~capymoa.stream.Stream.next_instance` ``` -------------------------------- ### HTML: Creating a Simple List Source: https://capymoa.org/_sources/notebooks/00_getting_started This HTML snippet shows how to create an unordered list (`