Machine Learning
Real Machine Learning — simple, practical, and built on experience. Learn step by step with clear explanations and working code. Admin: @HusseinSheikho || @Hussein_Sheikho
نمایش بیشتر📈 تحلیل کانال تلگرام Machine Learning
کانال Machine Learning (@machinelearning9) در بخش زبانی انگلیسی بازیگری فعال است. در حال حاضر جامعه شامل 40 140 مشترک است و جایگاه 3 371 را در دسته فناوری و برنامهها و رتبه 230 را در منطقه سوريا دارد.
📊 شاخصهای مخاطب و پویایی
از زمان ایجاد در невідомо، پروژه رشد سریعی داشته و 40 140 مشترک جذب کرده است.
بر اساس آخرین دادهها در تاریخ 26 ژوئن, 2026، کانال فعالیت پایداری دارد. در ۳۰ روز گذشته تغییر اعضا برابر 429 و در ۲۴ ساعت گذشته برابر 20 بوده و همچنان دسترسی گستردهای حفظ شده است.
- وضعیت تأیید: تأیید نشده
- نرخ تعامل (ER): میانگین تعامل مخاطب 1.83% است و در ۲۴ ساعت نخست پس از انتشار، محتوا معمولاً 1.60% واکنش نسبت به کل مشترکان کسب میکند.
- دسترسی پستها: هر پست به طور میانگین 735 بازدید دریافت میکند. در اولین روز معمولاً 643 بازدید جمعآوری میشود.
- واکنشها و تعامل: مخاطبان بهطور فعال حمایت میکنند؛ میانگین واکنش به هر پست 2 است.
- علایق موضوعی: محتوا بر موضوعات کلیدی مانند distance, insidead, gpu, learning, degree تمرکز دارد.
📝 توضیح و سیاست محتوایی
نویسنده این فضا را محل بیان دیدگاههای شخصی توصیف میکند:
“Real Machine Learning — simple, practical, and built on experience.
Learn step by step with clear explanations and working code.
Admin: @HusseinSheikho || @Hussein_Sheikho”
به لطف بهروزرسانیهای پرتکرار (آخرین داده در تاریخ 27 ژوئن, 2026)، کانال همواره بهروز و دارای دسترسی بالاست. تحلیلها نشان میدهد مخاطبان بهطور فعال با محتوا تعامل دارند و آن را به نقطه اثرگذاری مهم در دسته فناوری و برنامهها تبدیل کردهاند.
import numpy as np
arr = np.array([[10, 20], [30, 40]])
np.savetxt("output.txt", arr, fmt="%d", delimiter=",")
# Check output.txt, it will contain:
# 10,20
# 30,40
Python tip:
Save and load arrays in NumPy's native binary format (.npy) using np.save() and np.load().
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
np.save("my_array.npy", arr)
loaded_arr = np.load("my_array.npy")
print(loaded_arr)
Python tip:
Handle missing data using np.nan (Not a Number).
import numpy as np
arr_with_nan = np.array([1, 2, np.nan, 4])
print(arr_with_nan)
Python tip:
Check for NaN values using np.isnan().
import numpy as np
arr = np.array([1, 2, np.nan, 4])
is_nan_arr = np.isnan(arr)
print(is_nan_arr) # Output: [False False True False]
Python tip:
Use np.inf for infinity.
import numpy as np
result = 10 / np.inf
print(result) # Output: 0.0
Python tip:
Check for infinite values using np.isinf().
import numpy as np
arr = np.array([1, np.inf, -np.inf, 4])
is_inf_arr = np.isinf(arr)
print(is_inf_arr) # Output: [False True True False]
Python tip:
Replace NaN values using boolean indexing or np.nan_to_num().
import numpy as np
arr = np.array([1, 2, np.nan, 4, np.nan])
arr[np.isnan(arr)] = 0 # Replace NaN with 0
print(arr)
Python tip:
Check if all elements in a boolean array are true using np.all().
import numpy as np
bool_arr = np.array([True, True, True])
print(np.all(bool_arr)) # Output: True
Python tip:
Check if any element in a boolean array is true using np.any().
import numpy as np
bool_arr = np.array([False, False, True])
print(np.any(bool_arr)) # Output: True
Python tip:
Get the dimensions of an array by unpacking .shape.
import numpy as np
matrix = np.zeros((2, 3, 4))
d1, d2, d3 = matrix.shape
print(f"Dim 1: {d1}, Dim 2: {d2}, Dim 3: {d3}")
Python tip:
Use np.transpose() with a tuple of axes to reorder dimensions for multi-dimensional arrays.
import numpy as np
arr_3d = np.arange(24).reshape(2, 3, 4)
# Swap axis 0 and 2
transposed_arr = np.transpose(arr_3d, (2, 1, 0)) # (4, 3, 2)
print(transposed_arr.shape)
Python tip:
Generate a diagonal array from a 1D array or extract the diagonal from a 2D array using np.diag().
import numpy as np
arr_1d = np.array([1, 2, 3])
diag_matrix = np.diag(arr_1d)
print(diag_matrix)
Python tip:
Repeat elements of an array using np.repeat().
import numpy as np
arr = np.array([1, 2])
repeated_arr = np.repeat(arr, 3) # Each element repeated 3 times
print(repeated_arr) # Output: [1 1 1 2 2 2]
Python tip:
Repeat an entire array or tile it using np.tile().
import numpy as np
arr = np.array([[1, 2], [3, 4]])
tiled_arr = np.tile(arr, (2, 1)) # Repeat 2 times vertically, 1 time horizontally
print(tiled_arr)
Python tip:
Dot product of two 1D arrays or matrix multiplication of 2D arrays with np.dot().
import numpy as np
v1 = np.array([1, 2])
v2 = np.array([3, 4])
dot_product = np.dot(v1, v2)
print(dot_product) # Output: 11 (1*3 + 2*4)
Python tip:
Compute the outer product of two vectors using np.outer().
import numpy as np
v1 = np.array([1, 2])
v2 = np.array([3, 4, 5])
outer_product = np.outer(v1, v2)
print(outer_product)
Python tip:
Calculate the inverse of a matrix using np.linalg.inv().
import numpy as np
matrix = np.array([[1, 2], [3, 4]])
inverse = np.linalg.inv(matrix)
print(inverse)
Python tip:
Calculate the determinant of a matrix using np.linalg.det().import numpy as np
np.random.seed(42)
print(np.random.rand(2))
np.random.seed(42) # Resetting seed
print(np.random.rand(2)) # Same output as above
Python tip:
Create a deep copy of an array using .copy() to avoid unintended modifications.
import numpy as np
original = np.array([1, 2, 3])
copy = original.copy()
copy[0] = 100
print(original) # Output: [1 2 3] (original is unchanged)
print(copy) # Output: [100 2 3]
Python tip:
Using arr[index] for assignment modifies the original array (views, not copies, for slices).
import numpy as np
original = np.arange(5)
view = original[1:4]
view[0] = 99 # Modifies original[1]
print(original) # Output: [ 0 99 2 3 4]
Python tip:
Compare arrays element-wise using comparison operators, resulting in a boolean array.
import numpy as np
a = np.array([1, 2, 3])
b = np.array([1, 0, 4])
print(a == b) # Output: [ True False False]
print(a > b) # Output: [False True False]
Python tip:
Use boolean indexing to select elements based on a condition.
import numpy as np
arr = np.array([10, 25, 5, 30, 15])
filtered_arr = arr[arr > 20] # Select elements greater than 20
print(filtered_arr) # Output: [25 30]
Python tip:
Combine multiple boolean conditions using & (AND), | (OR), and ~ (NOT) for element-wise logical operations.
import numpy as np
arr = np.array([1, 6, 2, 7, 3, 8])
filtered = arr[(arr > 3) & (arr < 8)] # Elements greater than 3 AND less than 8
print(filtered) # Output: [6 7]
Python tip:
Use np.clip() to limit the values in an array to a specified range.
import numpy as np
arr = np.array([1, 10, 3, 15, 6])
clipped_arr = np.clip(arr, 3, 10) # Values below 3 become 3, above 10 become 10
print(clipped_arr) # Output: [ 3 10 3 10 6]
Python tip:
Round array elements to the nearest integer using np.round().
import numpy as np
arr = np.array([1.2, 2.7, 3.5, 4.1])
rounded_arr = np.round(arr)
print(rounded_arr) # Output: [1. 3. 4. 4.]
Python tip:
Use np.floor() to round down to the nearest integer.
import numpy as np
arr = np.array([1.2, 2.7, 3.5, 4.9])
floored_arr = np.floor(arr)
print(floored_arr) # Output: [1. 2. 3. 4.]
Python tip:
Use np.ceil() to round up to the nearest integer.
import numpy as np
arr = np.array([1.2, 2.7, 3.5, 4.1])
ceiled_arr = np.ceil(arr)
print(ceiled_arr) # Output: [2. 3. 4. 5.]
Python tip:
Calculate the absolute value of each element using np.abs().
import numpy as np
arr = np.array([-1, 5, -3, 0])
abs_arr = np.abs(arr)
print(abs_arr) # Output: [1 5 3 0]
Python tip:
Transpose a 2D array using the .T attribute or np.transpose().
import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6]])
transposed_matrix = matrix.T
print(transposed_matrix)
Python tip:
Use np.isin() to check if elements of one array are present in another.
import numpy as np
arr1 = np.array([1, 2, 3, 4, 5])
arr2 = np.array([2, 4, 6])
presence = np.isin(arr1, arr2)
print(presence) # Output: [False True False True False]
Python tip:
Use np.diff() to calculate the difference between consecutive elements.
import numpy as np
arr = np.array([1, 3, 7, 12, 10])
differences = np.diff(arr)
print(differences) # Output: [ 2 4 5 -2]
Python tip:
Load data from a text file into a NumPy array using np.loadtxt().
import numpy as np
# Create a dummy file for the example
with open("data.txt", "w") as f:
f.write("1 2 3\n")
f.write("4 5 6\n")
data = np.loadtxt("data.txt")
print(data)
Python tip:
Save a NumPy array to a text file using np.savetxt().np.hstack() or np.column_stack().
import numpy as np
a = np.array([[1], [2]])
b = np.array([[3], [4]])
stacked_horz = np.hstack((a, b))
print(stacked_horz)
Python tip:
Split an array into multiple sub-arrays using np.split().
import numpy as np
arr = np.arange(12).reshape(2, 6)
split_arr = np.split(arr, 3, axis=1) # Split into 3 arrays along column axis
print(split_arr)
Python tip:
Use np.where() for conditional element selection, similar to a ternary operator.
import numpy as np
arr = np.array([1, 5, 2, 8, 3])
result = np.where(arr > 4, arr * 10, arr) # if > 4, multiply by 10, else keep original
print(result) # Output: [ 1 50 2 80 3]
Python tip:
Calculate the sum of all elements in an array using np.sum().
import numpy as np
arr = np.array([[1, 2], [3, 4]])
total_sum = np.sum(arr)
print(total_sum) # Output: 10
Python tip:
Calculate the sum along a specific axis (axis=0 for columns, axis=1 for rows).
import numpy as np
arr = np.array([[1, 2], [3, 4]])
sum_rows = np.sum(arr, axis=1) # Sum of each row
sum_cols = np.sum(arr, axis=0) # Sum of each column
print(f"Row sums: {sum_rows}")
print(f"Column sums: {sum_cols}")
Python tip:
Find the minimum and maximum values in an array using np.min() and np.max().
import numpy as np
arr = np.array([1, 5, 2, 8, 3])
print(np.min(arr)) # Output: 1
print(np.max(arr)) # Output: 8
Python tip:
Find the index of the minimum/maximum value using np.argmin() and np.argmax().
import numpy as np
arr = np.array([1, 5, 2, 8, 3])
print(np.argmin(arr)) # Output: 0 (index of 1)
print(np.argmax(arr)) # Output: 3 (index of 8)
Python tip:
Calculate the mean (average) of array elements using np.mean().
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(np.mean(arr)) # Output: 3.0
Python tip:
Calculate the median of array elements using np.median().
import numpy as np
arr = np.array([1, 5, 2, 8, 3])
print(np.median(arr)) # Output: 3.0
Python tip:
Calculate the standard deviation using np.std().
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(np.std(arr))
Python tip:
Calculate the variance using np.var().
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(np.var(arr))
Python tip:
Sort an array using np.sort(). It returns a sorted copy, leaving the original array unchanged.
import numpy as np
arr = np.array([3, 1, 4, 1, 5, 9, 2])
sorted_arr = np.sort(arr)
print(sorted_arr)
print(arr) # Original array is unchanged
Python tip:
Sort an array in-place using the .sort() method.
import numpy as np
arr = np.array([3, 1, 4, 1, 5, 9, 2])
arr.sort() # Sorts the array itself
print(arr)
Python tip:
Get the unique elements of an array using np.unique().
import numpy as np
arr = np.array([1, 1, 2, 3, 2, 4, 1, 5])
unique_elements = np.unique(arr)
print(unique_elements) # Output: [1 2 3 4 5]
Python tip:
Generate random floating-point numbers in [0.0, 1.0) using np.random.rand().
import numpy as np
random_floats = np.random.rand(3, 2) # 3 rows, 2 columns
print(random_floats)
Python tip:
Generate random integers within a specified range using np.random.randint().
import numpy as np
random_ints = np.random.randint(0, 10, size=(2, 3)) # integers between 0 (inclusive) and 10 (exclusive)
print(random_ints)
Python tip:
Set a random seed using np.random.seed() for reproducible results.[start:stop:step]. stop is exclusive.
import numpy as np
arr = np.arange(10) # [0, 1, ..., 9]
slice_arr = arr[2:7:2] # elements from index 2 to 6, with step 2
print(slice_arr) # Output: [2, 4, 6]
Python tip:
Slice rows and columns in 2D arrays: [row_slice, col_slice].
import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
sub_matrix = matrix[0:2, 1:3] # rows 0 and 1, columns 1 and 2
print(sub_matrix)
Python tip:
Use -1 for negative indexing to access elements from the end of the array.
import numpy as np
arr = np.array([10, 20, 30, 40, 50])
print(arr[-1]) # Output: 50 (last element)
print(arr[-3:]) # Output: [30, 40, 50] (last three elements)
Python tip:
Reshape an array to a new shape using the .reshape() method. The new shape must have the same total number of elements.
import numpy as np
arr = np.arange(12) # 12 elements
reshaped_arr = arr.reshape(3, 4) # 3 rows, 4 columns
print(reshaped_arr)
Python tip:
Use -1 in reshape() to let NumPy automatically calculate one dimension.
import numpy as np
arr = np.arange(12)
reshaped_arr = arr.reshape(3, -1) # 3 rows, NumPy calculates 4 columns
print(reshaped_arr)
Python tip:
Flatten an array into a 1D array using .ravel() or .flatten(). .ravel() returns a view where possible, .flatten() always returns a copy.
import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6]])
flat_arr = matrix.ravel()
print(flat_arr)
Python tip:
Convert an array to a different data type using .astype().
import numpy as np
arr_float = np.array([1.5, 2.7, 3.1])
arr_int = arr_float.astype(int)
print(arr_int) # Output: [1 2 3]
Python tip:
Perform element-wise arithmetic operations directly on arrays.
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(a + b) # Addition
print(a * b) # Multiplication
Python tip:
Multiply arrays element-wise, not matrix multiplication, using *.
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6], [7, 8]])
print(a * b) # Element-wise product
Python tip:
Perform matrix multiplication using the @ operator (Python 3.5+) or np.dot().
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6], [7, 8]])
matrix_product = a @ b # or np.dot(a, b)
print(matrix_product)
Python tip:
Broadcasting allows operations on arrays of different shapes if compatible.
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
scalar = 10
print(arr + scalar) # Scalar is broadcast to all elements
Python tip:
Broadcasting also works between arrays with compatible dimensions.
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]]) # shape (2, 3)
b = np.array([10, 20, 30]) # shape (3,)
print(a + b) # b is broadcast across rows of a
Python tip:
Use np.newaxis (or None) to add a new dimension for broadcasting.
import numpy as np
vec = np.array([1, 2, 3]) # shape (3,)
col_vec = vec[:, np.newaxis] # shape (3, 1)
print(col_vec)
Python tip:
Concatenate arrays along an existing axis using np.concatenate().
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])
c = np.concatenate((a, b), axis=0) # Concatenate vertically
print(c)
Python tip:
Stack arrays vertically (row-wise) using np.vstack() or np.row_stack().
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
stacked_vert = np.vstack((a, b))
print(stacked_vert)np for convenience.
import numpy as np
print(np.__version__)
Python tip:
Create a NumPy array from a Python list or tuple using np.array().
import numpy as np
my_list = [1, 2, 3, 4, 5]
arr = np.array(my_list)
print(arr)
Python tip:
Initialize an array filled with zeros using np.zeros(), specifying the shape.
import numpy as np
zeros_array = np.zeros((3, 4)) # 3 rows, 4 columns
print(zeros_array)
Python tip:
Initialize an array filled with ones using np.ones(), specifying the shape and optionally dtype.
import numpy as np
ones_array = np.ones((2, 3), dtype=int)
print(ones_array)
Python tip:
Create an empty array with np.empty(). Its initial content is random and depends on memory.
import numpy as np
empty_array = np.empty((2, 2))
print(empty_array)
Python tip:
Generate a sequence of numbers with np.arange(), similar to Python's range().
import numpy as np
sequence = np.arange(0, 10, 2) # start, stop (exclusive), step
print(sequence)
Python tip:
Generate evenly spaced numbers over a specified interval using np.linspace().
import numpy as np
evenly_spaced = np.linspace(0, 10, 5) # start, stop (inclusive), number of samples
print(evenly_spaced)
Python tip:
Create an array filled with a specific constant value using np.full().
import numpy as np
full_array = np.full((2, 2), 7)
print(full_array)
Python tip:
Create an identity matrix (square matrix with ones on the main diagonal) using np.eye() or np.identity().
import numpy as np
identity_matrix = np.eye(3) # 3x3 identity matrix
print(identity_matrix)
Python tip:
Create a new array of zeros with the same shape and data type as an existing array using np.zeros_like().
import numpy as np
original_array = np.array([[1, 2], [3, 4]])
like_zeros = np.zeros_like(original_array)
print(like_zeros)
Python tip:
Check the shape (dimensions) of an array using the .shape attribute.
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr.shape) # Output: (2, 3)
Python tip:
Check the number of dimensions of an array using the .ndim attribute.
import numpy as np
arr_1d = np.array([1, 2, 3])
arr_2d = np.array([[1, 2], [3, 4]])
print(arr_1d.ndim) # Output: 1
print(arr_2d.ndim) # Output: 2
Python tip:
Get the total number of elements in an array using the .size attribute.
import numpy as np
arr = np.zeros((3, 4))
print(arr.size) # Output: 12 (3 * 4)
Python tip:
Determine the data type of elements in an array using the .dtype attribute.
import numpy as np
arr_int = np.array([1, 2, 3])
arr_float = np.array([1.0, 2.0])
print(arr_int.dtype) # Output: int64 (or int32 depending on system)
print(arr_float.dtype) # Output: float64
Python tip:
Specify the data type when creating an array for memory efficiency or specific operations.
import numpy as np
arr = np.array([1, 2, 3], dtype=np.int8)
print(arr.dtype)
Python tip:
Access individual elements using square brackets [] with zero-based indexing.
import numpy as np
arr = np.array([10, 20, 30, 40])
print(arr[0]) # Output: 10
print(arr[2]) # Output: 30
Python tip:
For 2D arrays, use [row_index, col_index] to access elements.
import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(matrix[0, 0]) # Output: 1
print(matrix[1, 2]) # Output: 6
اکنون در دسترس! پژوهش تلگرام ۲۰۲۵ — مهمترین بینشهای سال 
