-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
583 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
content/c/concepts/pointers/terms/double-pointer/double-pointer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
Title: 'Double Pointer' | ||
Description: 'Holds the memory address of a pointer.' | ||
Subjects: | ||
- 'Code Foundations' | ||
- 'Computer Science' | ||
Tags: | ||
- 'Pointers' | ||
- 'Memory' | ||
- 'Variables' | ||
- 'Arrays' | ||
CatalogContent: | ||
- 'learn-c' | ||
- 'paths/computer-science' | ||
--- | ||
|
||
In C, a **double pointer** is a [pointer](https://www.codecademy.com/resources/docs/c/concepts/pointers/terms/pointer/pointer) that holds the memory address of another pointer. It allows indirect access to the value of a variable. | ||
|
||
## Syntax | ||
|
||
A double pointer is declared using two asterisks (`**`) before the pointer variable name: | ||
|
||
```pseudo | ||
type **name | ||
``` | ||
|
||
- `type`: The type of data the double pointer will point to (e.g., `int`, `char`, etc.). | ||
- `name`: The identifier for the double pointer. | ||
|
||
## Example | ||
|
||
The following example demonstrates how a double pointer is declared and used: | ||
|
||
```c | ||
# include <stdio.h> | ||
|
||
int main() { | ||
int value = 35; | ||
int *pointer = &value; // Pointer to an integer (stores the address of 'value') | ||
int **doublePointer = &pointer; // Double pointer to an integer pointer (stores the address of 'pointer') | ||
|
||
// Printing the values | ||
printf("Value of value: %d\n", value); // Direct access to value | ||
printf("Value of *pointer: %d\n", *pointer); // Dereferencing pointer to access value | ||
printf("Value of **doublePointer: %d\n", **doublePointer); // Dereferencing double pointer twice to access value | ||
|
||
// Printing the addresses | ||
printf("Address of value: %p\n", (void*)&value); // Address of the variable 'value' | ||
printf("Address of pointer: %p\n", (void*)&pointer); // Address of the pointer 'pointer' | ||
printf("Address of doublePointer: %p\n", (void*)&doublePointer); // Address of the double pointer 'doublePointer' | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
The above code will give the following output: | ||
|
||
```shell | ||
Value of value: 35 | ||
Value of *pointer: 35 | ||
Value of **doublePointer: 35 | ||
Address of value: 0x7ffcbffdcc14 | ||
Address of pointer: 0x7ffcbffdcc18 | ||
Address of doublePointer: 0x7ffcbffdcc20 | ||
``` | ||
|
||
In the example: | ||
|
||
- `value` is an integer variable. | ||
- `pointer` is a pointer tha stores the address of `value`. | ||
- `doublePointer` is a double pointer that stores the address of the pointer. |
33 changes: 33 additions & 0 deletions
33
content/general/concepts/artificial-intelligence/artificial-intelligence.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
Title: 'Artificial Intelligence' | ||
Description: 'Simulates human intelligence in computers, enabling learning, reasoning, and problem-solving to provide solutions across various tasks.' | ||
Subjects: | ||
- 'AI' | ||
- 'Computer Science' | ||
Tags: | ||
- 'AI' | ||
- 'Algorithms' | ||
- 'Automation' | ||
CatalogContent: | ||
- 'paths/computer-science' | ||
- 'paths/data-science' | ||
--- | ||
|
||
**Artificial Intelligence (AI)** is described as the simulation of human intelligence in computer systems. AI technology can perform learning, reasoning, and problem-solving tasks, enabling solutions to a variety of complex problems. AI systems can range from simple algorithms, such as those making product recommendations based on purchase history, to complex systems that power self-driving cars, planning routes, and avoiding obstacles without human intervention. The demand for AI-powered solutions is growing rapidly and intersecting almost every aspect of our daily lives. | ||
|
||
## Types of AI | ||
|
||
- **Reactive Machines AI**: These are the most basic AI systems. They do not have memory or use past data to form decisions or factor into solutions. They react to specific inputs with specific outputs. | ||
- **Limited Memory AI**: These systems can use memory and stored data to make future decisions. However, they only have temporary memory, which is stored briefly. | ||
- **Theory of Mind AI**: These advanced AI systems involve machines that can understand emotions, behaviors, and interactions, making them more human-like in their ability to interact with humans. | ||
- **Self-Aware AI**: This would be the most advanced type of AI system and is currently hypothetical. In this type of system, a machine would have a defined consciousness and be self-aware. It would be able to make decisions, feel emotions, and act on them based on its own intentions and desires. | ||
|
||
## Applications of AI | ||
|
||
Artificial Intelligence plays a significant role in various fields of computer science and programming. The most popular applications include: | ||
|
||
- **Business**: AI is playing an increasingly important role in businesses. AI-powered tools help collect, analyze, and visualize data efficiently, leading to improved decision-making, productivity, and cost reduction. | ||
- **Healthcare**: AI assists doctors in diagnosing diseases, developing treatments, and providing personalized care to patients. | ||
- **Education**: AI can personalize learning, enhance student engagement, and automate administrative tasks for schools and organizations. | ||
- **Finance**: AI aids financial institutions by personalizing services and products, managing risk and fraud, ensuring compliance, and automating operations to reduce costs. | ||
- **Manufacturing**: AI is used in manufacturing including automating tasks, such as assembly and inspection, optimizing production processes, and can be used to detect defects and improve quality control. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
Title: 'Linux' | ||
Description: 'Free and open-source operating system kernel that forms the foundation of numerous operating systems (distributions).' | ||
Subjects: | ||
- 'Computer Science' | ||
- 'Code Foundations' | ||
Tags: | ||
- 'Developer Tools' | ||
- 'Linux' | ||
- 'Operating Systems' | ||
- 'Unix' | ||
CatalogContent: | ||
- 'paths/computer-science' | ||
- 'paths/code-foundations' | ||
--- | ||
|
||
**Linux** was created by Linus Torvalds in 1991 as an alternative to proprietary Unix systems. It has since grown into a powerful, secure, and highly customizable operating system that powers everything from personal computers to servers, smartphones (Android), and supercomputers. The Linux ecosystem is supported by a vast community of developers and users who contribute to its continuous development and improvement. | ||
|
||
## Working | ||
|
||
Linux operates on a kernel-based architecture, where the kernel manages hardware resources and provides essential services to higher-level software. It supports a multi-user, multi-tasking environment, allowing processes to run concurrently while securely sharing system resources among users. The system follows a hierarchical file structure, starting from the root directory (`/`), where all devices and resources are represented as files. | ||
|
||
## Architecture of Linux | ||
|
||
![Linux Architecture](https://raw.githubusercontent.com/Codecademy/docs/main/media/general-linux.png) | ||
|
||
- Hardware Layer (Core) | ||
|
||
- Contains physical components like CPU, memory, and storage devices | ||
- Forms the base layer, interfacing directly with hardware | ||
|
||
- Kernel Layer | ||
|
||
- Core of the Linux operating system | ||
- Manages hardware resources, memory, and processes | ||
- Provides essential services and hardware abstraction | ||
- Handles system calls and device drivers | ||
|
||
- Shell Layer | ||
|
||
- A command-line interpreter that bridges the user and kernel | ||
- Processes user commands and scripts | ||
- Examples include Bash, Zsh, and Fish | ||
|
||
- Application Layer (Outermost) | ||
- Includes user applications, GUI interfaces, and system utilities | ||
- Supports third-party applications and system tools | ||
|
||
This layered architecture follows a hierarchical structure where each layer communicates with adjacent layers, with the kernel serving as the critical intermediary between hardware and software components. Each outer layer depends on the services provided by the inner layers, creating a robust and modular system design. | ||
|
||
## Linux Commands | ||
|
||
| Command | Description | Example Usage | | ||
| --------- | ---------------------------------------- | ----------------------------- | | ||
| `ls` | List files and directories | `ls -l` | | ||
| `cd` | Changes the current directory | `cd /home/user` | | ||
| `pwd` | Displays the current directory path | `pwd` | | ||
| `mkdir` | Creates a new directory | `mkdir new_folder` | | ||
| `rm` | Deletes files or directories | `rm file.txt` | | ||
| `rmdir` | Removes empty directories | `rmdir empty_folder` | | ||
| `cp` | Copies files or directories | `cp source.txt destination/` | | ||
| `mv` | Moves or rename files and directories | `mv old.txt new.txt` | | ||
| `cat` | Displays file contents | `cat file.txt` | | ||
| `nano` | Edits a file using the nano editor | `nano file.txt` | | ||
| `vim` | Edits a file using the Vim editor | `vim file.txt` | | ||
| `touch` | Creates an empty file | `touch newfile.txt` | | ||
| `chmod` | Modifies file permissions | `chmod 755 script.sh` | | ||
| `chown` | Changes file ownership | `chown user:group file.txt` | | ||
| `find` | Searches for files in a directory | `find /home -name "*.txt"` | | ||
| `grep` | Searches for a pattern inside files | `grep "error" logfile.log` | | ||
| `ps` | Displays running processes | `ps aux` | | ||
| `kill` | Terminates a process by its ID | `kill 1234` | | ||
| `top` | Shows system resource usage in real time | `top` | | ||
| `df` | Shows disk space usage | `df -h` | | ||
| `du` | Shows directory size | `du -sh folder/` | | ||
| `tar` | Archives multiple files | `tar -cvf archive.tar files/` | | ||
| `unzip` | Extracts files from a ZIP archive | `unzip archive.zip` | | ||
| `wget` | Downloads a file from the internet | `wget https://example.com` | | ||
| `curl` | Fetches data from a URL | `curl -O https://example.com` | | ||
| `echo` | Prints text to the terminal | `echo "Hello, World!"` | | ||
| `whoami` | Displays the current logged-in user | `whoami` | | ||
| `uptime` | Shows system uptime | `uptime` | | ||
| `history` | Displays command history | `history` | | ||
| `clear` | Clears the terminal screen | `clear` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
Title: 'Processor' | ||
Description: 'A processor is a hardware component, typically a chip, that executes instructions and performs data processing tasks in a computer or electronic device.' | ||
Subjects: | ||
- 'Computer Science' | ||
- 'Information Technology' | ||
Tags: | ||
- 'Memory' | ||
- 'Components' | ||
CatalogContent: | ||
- 'paths/computer-science' | ||
- 'paths/front-end-engineer-career-path' | ||
--- | ||
|
||
A **processor** is a hardware component that interprets and executes instructions from programs or data. It performs calculations, logic operations, and manages data flow within a system. Processors are essential for a wide range of tasks in computing and electronics, and are found in devices like computers, smartphones, and more. | ||
|
||
## History | ||
|
||
The history of processors ranges from primitive vacuum tubes to multi-core processors being able to handle tons of workload. Some key milestones in their history include: | ||
|
||
- **1940s-1950s**: Early computers used bulky vacuum tubes for processing, which made them large and inefficient. | ||
- **1960s**: The invention of transistors led to smaller, faster, and more reliable processors. | ||
- **1970s**: The Intel 4004, the first microprocessor, integrated all processing functions into a single chip. | ||
- **1980s**: The Intel 8086 introduced the x86 architecture, which powered personal computers like the IBM PC. | ||
- **1990s**: The Intel Pentium processors revolutionized personal computer performance. | ||
- **2000s-Present**: Multi-core processors enabled improved multitasking, while ARM chips became dominant in mobile devices. | ||
- **2010s-Present**: Processors became smaller and more powerful with nanometer technology, and AI-specific chips began to emerge. | ||
|
||
## Types of Processors | ||
|
||
Depending upon their function, processors are divided into many types. Some of them are: | ||
|
||
- **Central Processing Unit (CPU)**: The primary processor in a computer, responsible for executing the majority of instructions in a program. It handles tasks such as arithmetic, logic, and data management. | ||
- **Graphics Processing Unit (GPU)**: A specialized processor designed for graphics-related tasks, such as rendering images, video processing, and running complex simulations. GPUs are commonly found in gaming systems, workstations, and high-performance computing applications. | ||
- **Digital Signal Processor (DSP)**: A processor optimized for signal processing tasks, including sound, image, and video processing. DSPs are used in devices like smartphones, audio equipment, and telecommunications systems. | ||
- **Application-Specific Integrated Circuit (ASIC)**: A custom-designed processor for a specific application, often used in specialized systems such as cryptocurrency mining or network equipment. | ||
- **Microcontrollers**: Small, embedded processors found in everyday devices like microwaves, washing machines, and cars. They are often responsible for managing tasks and controls in these devices. | ||
|
||
Additionally, as artificial intelligence (AI) continues to grow, specialized processors called **Neural Processing Units (NPUs)**, also known as AI accelerators, are being developed to handle AI-specific workloads more efficiently. |
90 changes: 90 additions & 0 deletions
90
content/python/concepts/statsmodels/terms/diagnostic-plots/diagnostic-plots.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
Title: 'Diagnostic Plots' | ||
Description: 'Diagnostic plots are visual tools used to assess the validity of regression model assumptions, detect anomalies, and evaluate model performance.' | ||
Subjects: | ||
- 'Machine Learning' | ||
- 'Data Science' | ||
Tags: | ||
- 'Statistics' | ||
- 'Properties' | ||
- 'Models' | ||
- 'Data' | ||
CatalogContent: | ||
- 'learn-python-3' | ||
- 'paths/computer-science' | ||
--- | ||
|
||
Diagnostic plots are essential tools for evaluating the assumptions and performance of regression models. In the context of linear regression, these plots help identify potential issues such as non-linearity, non-constant variance, outliers, high leverage points, and collinearity. The `statsmodels` library in Python provides several functions to generate these diagnostic plots, aiding in assessing model fit and validity. | ||
|
||
Common diagnostic plots include: | ||
|
||
- **Residual plots**: Check for homoscedasticity and non-linearity. | ||
- **Q-Q plots**: Assess the normality of residuals. | ||
- **Leverage plots**: Identify influential points. | ||
- **Scale-location plots**: Detect patterns in residual variance. | ||
|
||
## Syntax | ||
|
||
There are several different methods for generating diagnostic plots in statsmodels. Two common methods are `plot_partregress_grid()` and `plot_regress_exog()`. These methods work with a fitted regression results object. | ||
|
||
### `plot_partregress_grid()` | ||
|
||
The `plot_partregress_grid()` method generates diagnostic plots for all explanatory variables in the model. It helps assess the relationship between the residuals and each independent variable. | ||
|
||
The syntax for using `plot_partregress_grid()` is: | ||
|
||
```psuedo | ||
results.plot_partregress_grid() | ||
``` | ||
|
||
- `results` refers to the fitted regression results object. | ||
|
||
### `plot_regress_exog()` | ||
|
||
The `plot_regress_exog()` method generates residual plots for a specific independent variable. This can help check the assumption of linearity with respect to a particular predictor. | ||
|
||
The syntax for using `plot_regress_exog()` is: | ||
|
||
```pseudo | ||
results.plot_regress_exog(exog_idx) | ||
``` | ||
|
||
- `results` refers to the fitted regression results object. | ||
- `exog_idx` is the index of the explanatory variable whose relationship with the dependent variable you want to plot. | ||
|
||
## Example | ||
|
||
Below is an example demonstrating how to generate diagnostic plots for a linear regression model using `statsmodels`: | ||
|
||
```py | ||
import statsmodels.api as sm | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
|
||
# Create synthetic data | ||
np.random.seed(0) | ||
X = np.random.rand(100, 2) | ||
X = sm.add_constant(X) # Add constant (intercept) | ||
y = X[:, 1] + X[:, 2] + np.random.randn(100) # Dependent variable with some noise | ||
|
||
# Fit linear regression model | ||
model = sm.OLS(y, X) | ||
results = model.fit() | ||
|
||
# Generate diagnostic plots for all variables | ||
fig = plt.figure(figsize=(10, 8)) | ||
fig = sm.graphics.plot_partregress_grid(results) | ||
plt.show() | ||
|
||
# Alternatively, generate a residual plot for the first independent variable | ||
fig = plt.figure(figsize=(10, 8)) | ||
fig = sm.graphics.plot_regress_exog(results, 1) | ||
plt.show() | ||
``` | ||
|
||
The output will be as follows: | ||
|
||
![Diagnostic plots for all variables](https://raw.githubusercontent.com/Codecademy/docs/main/media/partial-regression-plot.png) | ||
|
||
![A residual plot for the first independent variable](https://raw.githubusercontent.com/Codecademy/docs/main/media/regression-plot-for-x1.png) |
55 changes: 55 additions & 0 deletions
55
content/pytorch/concepts/tensor-operations/terms/numel/numel.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
Title: '.numel()' | ||
Description: 'Returns the total number of elements in a tensor.' | ||
Subjects: | ||
- 'AI' | ||
- 'Data Science' | ||
Tags: | ||
- 'AI' | ||
- 'Data Types' | ||
- 'Deep Learning' | ||
- 'Functions' | ||
CatalogContent: | ||
- 'intro-to-py-torch-and-neural-networks' | ||
- 'paths/data-science' | ||
--- | ||
|
||
In PyTorch, the **`.numel()`** method calculates the product of all dimensions of the tensor to determine its total size. It's particularly useful to know the total count of elements regardless of the tensor's shape or dimensionality. | ||
|
||
## Syntax | ||
|
||
```pseudo | ||
torch.numel(Tensor) | ||
``` | ||
|
||
- `Tensor`: The input tensor whose total number of elements is to be computed. | ||
|
||
It returns an integer representing the total number of elements in the given tensor. | ||
|
||
## Example | ||
|
||
The following example creates a _2x3_ tensor and demonstrates how `.numel()` counts all elements across all dimensions: | ||
|
||
```py | ||
import torch | ||
|
||
# Create a 2x3 tensor | ||
x = torch.randn(2, 3) | ||
print("Tensor x:") | ||
print(x) | ||
|
||
y = torch.numel(x) | ||
print("\nTotal number of elements:", y) | ||
``` | ||
|
||
The above code produces the following output: | ||
|
||
```shell | ||
Tensor x: | ||
tensor([[-1.0727, 0.3469, -1.2021], | ||
[ 0.0424, 0.1689, 2.6234]]) | ||
|
||
Total number of elements: 6 | ||
``` | ||
|
||
> **Note:** The output varies on each run because `torch.randn(2, 3)` generates random values from a normal distribution. |
Oops, something went wrong.