 .  
 


  #1
        ().     ,   ,    ,         ,     ,        .                     .        ,   ,     ,       .





 

 .  








 


 ,

        " ".          ,   ,     .

            ,    .             ,      ,    ,             .

          .          ,        .

         ,      ,  ,     ..        :

 : , Jupyter Notebook  Google Colab.    ,     ,         .

   (IDE):   PyCharm, Visual Studio Code,  Spyder.          ,        .

- : , repl.it  CodePen.          -      .

      :       -,       , , Python Tutor  Python  SQLFiddle  SQL.

      ,   ,         ,        .

  ,

 






 1:    



1.1   

  ()     ,    ,    ,    .      ,  ,        ,   ,   , ,  , , ,    .

         ,  , , , ,     .        ,    ,  ,     .

             ,                 .

    ,          ,   ,   .        :



1.  

       ,        ,     .              .      ,              .

         .    ,      ,        .        ,    ,      ,  , ,   .

       ,        .        ,    ,        .            ,       ,      ,    ,    .

          . ,     ,           .    ,           .

 :

        ,       ,      .

       ,          .

         ,         ,     .

        ,           .             .

  ,                .



2.  

         ,     .      ,        .         ,      ,    .

      ,           .             ,           .

                ,         .       ,    ,   ,  ,     .

      ,     ,             .   ,             ,        .



3.  

     ,        .       ,      ,             .

     ,      .      ,          ,    ,     ,   .

        .        ,    .       ,       .              ,            .

      ,  , , , ,     .       ,     ,   ,     .     ,              .

                   ,      .

,      ,   : A, B, C, D, E.         ,           . ,       A-B-C-D-E.

             .     ,                  . ,    A-B-C-D-E  A-C-D-B-E,     A-B-C-D-B-E.

    ,       . ,         .

         ,          .      ,          .

 ,              ,    ,         .



4.  

     ,      ,      .      ,         .              .

           .    ,        ,        .     ,       ,     .

       ,  ,              ; ,      ,     ; ,         .

,     ,      .                    .   ,        ,             .

           . ,     ,       ,  .       ,       .

       ,     , ,   . .       ,    ,    .

,       ,     ,             .

 ,          ,               .

 ,            ,      ,          .



5.    (Natural Language Processing, NLP)

   (NLP)      ,         .        ,       ,     ,    .

          .     ,    ,   ,       .        ,  ,     .

   NLP   ,          .                ,         .

 ,        ,    ,  ,     .       , , ,    ,             .

 ,         ,           ,            .



6.    (Reinforcement Learning)

   (Reinforcement Learning, RL)     ,     ,      .        ,   ,            .        ,          .

         "" (policy),              .       ,    ,        .

        . , RL     ,        ,               .  RL     ,          ,           .  ,        ,       ,   ,         .

          ,           .



7.     (Computer Vision)

    (Computer Vision)      ,       .          ,   ,      ,    ,       .

          ,         .       ,   , , ,    , ,      .

      ,            . ,      ,       ,         .

     ,         ,    .       ,          .

  ,         ,  ,         ,   ,         .

 ,          ,       ,   ,  , ,    .



8.    

            ,     ,           .            ,     ,     ,     .

        .     ,  ,    ,          . ,        ,         .

          .      ,      ,     ,           .               ,        ,               .

                ,        .     ,      ,         .



9.     

         ,          .       ,      ,     ,     .

             .            ,   ,       .  ,                   .

  ,               ,    ,      .             ,      ,        .

                ,            .           ,             ,  , ,    .



10.     

            ,        ,        .          ,      ,         .

              .       ,          . ,       -     ,      ,       ,           .

 ,            .        ,  ,      ,           .

 ,                 ,        .       ,   , , ,    ,           .

           .             ,    .          ,          .        ,        ,     .







1.2    

        ,            .        :

 

          ,            .               ,       .

   ,     ,       ,        . ,  ""     ,      ,         .

                  .    ,  ,        ,      .                        .

      ,    ,       . ,     ,         ,     .

          .       ,  ,        .

                   .     ,        ,    ,        .                     .

  

    20        ,        .               ,        .

            1950    "   ".       :    .    ,        .           ,        .              .

                    .      ,       ,         .                .

                .      ,      ,   .

             .  1950-      ,       .        " ",      .             .

     20     ,     ,      .   ,     ,         .

         .              .            .

         .               .        ,        .

         .           ,               .

  ,      . ,    ,     ,             .

 ,      ,    ,         .                  .

   

1956           ,              .             .  ,   ,  ,     ,         .

      ,        .  ,        ,       .               .   1950-     ,       ,   .

    ,      ,           .       ,         .

   ,    ,      ,              .         , ,   ,    .

 ,      .      ,     ,          .                ,       .

          ,            .                  .        ,                 .

        1956    1950-   1960-           ,         ,     .

  

 1970-80-          ,           .      ,         ,      ,  ,      .

                .       ,     ,   ,        .            .

 ,   ,           .       ,     ,      .                 .

     ,      ,         .                   .

 ,       ,           .                   .

       ,         .             ,         ,         ,            .

,    ,      .               .   ,          , ,                .

    

  20      21              .           ,       .  ,   ,      ,           .

        .         ,   ,   ,  ,  ,     .          ,      .

,            ,      ,   ,        .            ,   ,      .

           ,                 .

   

           ,        .             ,                .

        ,  ,     -.        ,             .

          ,   ,        .         ,       .

           ,     ,      .            .

          ,    ,      .            ,        .

 ,          ,      ,   ,         .






 2:    



2.1   

   ,    ,            .



 

       ,        ,          .      ,   ,    ,    ,    .                   ,    .  ,      ,       ,          .

        ,         .          ,           .

           .      ,         .      -,            .

          .         ,       .      ,                ,    ,           .

         ,        .         ,        .      ,    ,    ,           .

         ,           .        ,        ,         .

         ,          .                   ,   ,   .

                   .        ,             .

       ,        .     :

1.   :           .              .

2.    :     ,          .               .

3.  :             .          .

4.  :             .           .

5.  :          .    ,         .

6.  :               .    ,           .

7.  :  ,    ,       .            ,          .

8.  :             .                .

9.  :  ,         .   ,        ,   .

10.  :        ,      .               .

          .                .



 

           .            ,        .              .

            .           ,      .                   .

             . ,        ,       (, ,   . .).         ,        .

               .         ,     ,         .

                   ,                    .

                .              ,      ,         .

              .                   .

          ,             .      Q-, ,               .

                  ,         .        ,       ,             .

                  .    ,              .           ,        .

    ,               . ,   ,          ,           .

        ,                   . ,              ,            .

,            ,                   .            ,        .

 ,            ,                  .



  

              .              ,    .          , , ,     ,      .

                 .       ,     ,          . ,         ,       .

,   ,              .       , , ,    ,           .

             ,  .   -   ,      .        ,   ,       .

           ,          . ,    ,      ,     . ,      ,          .

 ,     ,     ,     .      ,     .         ,     ,   .

 ,       ,          ,             .

,             ,              .          ,    ,          .                     .



    

            .                .           ,        ,     .  ,            ,       ,      .

         ,         ,    . ,        ,       ,           .

           ,       .                  .   ,   ,      ,        .

       ,        .             ,          .

          ,    ,       ,   .      ,    ,   ,   ,        .

     ,         ,                    .                  .



          ,      ,          .     ,       ,                       .

       ,            . ,                     .             ,    ,            .

                    ,       ,     .               ,           .

          ,       . ,      ,        ,    .

                  .                      , ,    .

,           .            .        ,      .         ,      .

 ,                    ,              ,    .



        ,       ,     ,       .             ,       ,          .

        .     ,     ,        . ,           ,      .

         ,      .         ,   Q-,       -.

              ,              .       ,  , ,  ,    ,          .

            .  ,        Atari Breakout,    ,  ,        .

     ,   ,      .    ,     ,       .  ,        ,    ,      ,    .

        .         .       ,      ,     .

     ,   Q-     ,           .            ,     ,                .

             ,    ,  ,     .                   .




2.2   

        ,            .          , , ,     ,          .

             .        ,          .         ,         .

 ,       .            ,            . ,      ,             .

,          .   ,            ,             .  ,                .

        ,           .          ,     .

         .        ,        .       ,     .

         :

     :

1. :

   .

   .

  .

  .

 .

 .

2. :

     ,   .

     ,   .

          . :

1.  \( L(x) \)  "x ", \( M(x) \)  "x ", \( H(x) \)  "x  ", \( A(x) \)  "x  ".

2.        :

\( A(\text{}) \), \( A(\text{}) \), \( H(\text{}) \), \( H(\text{}) \), \( L(\text{}) \), \( M(\text{}) \).

3.      :

\( (H(x) \land L(x)) \Rightarrow A(x) \) (     ,   ).

\( (H(x) \land M(x)) \Rightarrow A(x) \) (     ,   ).

 ,              ,         .

       .          .          ,      .



      ,    ,    ,        .                .

          .   ,             ,             .

 ,      ,       .   ,        ,    ,       .

        "".        ,         ,  ,    . .            ,           .

       .      ,     ,          .       ,     ,         .

              .      ,       ,        ,    .

 ,           .   ,              ,       .

       ,    , ,    .           ,     , ,    .         , ,    ,      .

     ,      ,         . ,       "",     " ", "", "  " ..         ,  ,     .

                    .        ,           . ,             ,        .  ,              ,         .

                  .                    .

               ,          .         ,   ,  , -    .          ,   ,        .

             .                     ,    ,     .                      .

 ,           .       ,     ,       .        ,   ,     .                ,       .

            .      ,              . ,                            .

    ,      .          ,           . ,                    .

     ,     .                . ,              (,   )         .

    ,                   . ,                  .

                     -              .          ,           .

            :

1.    -:              ,     . ,          ,     .        , , "      '',       ''".

2.   :       ,    . ,           .        , , "     X  Y,        Z,      Z".

3.    :             . ,  ""  ""      "".      , , "    ,      .."

            ,           .        ,           ,     .  ,             ,        .

             ,    ,      .       ,         . ,                 .

                 .        ,         . ,                .




2.3      

           ,      .             ,         .

            ,             .           ,        .

              ,          .      ,       ,      .

             , ,        .                   .

,  ,  .     ,                .           ,    ,      ,      .

         .      ,          ,    .                 .

         ,      .      ,             .

  ,                   .

 ,      ,           ,   .     ,        ,  ,      .

     ,           .              . ,  "_(, )"   " "   ""  "".

      .     :   (?),    ,         ,    (?),  ,   - ,    .            .

      :

,     ,   ,   "(x)",    ,    .    ,        .

1.   (?): ?x (x).

    ,         .     x        "(x)".

2.   (?): ?x (x).

    ,          ,   .    -  x     ,    "(x)".

 ,           ,            .

         ,      .         ,   ,  ,     .              .

              ,         . ,                    .

         .          ,   ,     ,     .                ,        .

                 .        ,                . ,  ,  "  "  "  ",    ,  " ".

  , ,    ,      .       ,          . ,  ,  " "  "  ",     ,  "  ".

      ,           .         ,    .     ,               .

                .      ,      ,            .

               . ,     ,           ,    .       .

            (,  ),     (,  , )        (    ).

  . ,               .   ,       .   ,         ,   ,   ,    .

,       ,        ,   .                  .

 ,          ,         ,     .




2.4   

         ,             .    ,               .       ,        .

,   ,              .       ,          .             ,         .

             .          ,      .    ,      ,            .

    ,                    .         ,             .         ,          .

         ,              .         ,          .            .

        ,           .           ,             .            .

 ,      ,     ,                  .             ,         .

            . ,    ,                 .

        ,          ,        .      ,          ,        .

                .         ,        .

,               .         ,    ,          .

         ,          .

      ,           .            ,       . ,                 ,      .

      ,      ,          ,        .      ,             .            ,     ,     ,         .

       ,   . ,     ,     ,              .        ,        .

         .        ,     ,    ,       .     ,          .

             .      Python    Scikit-learn     :

```python

from sklearn.linear_model import SGDRegressor

import numpy as np

#        

model = SGDRegressor()

#       

X_initial = np.array([[1, 2], [3, 4]])

y_initial = np.array([3, 7])

model.partial_fit(X_initial, y_initial)

#    

X_new = np.array([[5, 6]])

y_new = np.array([11])

#      

model.partial_fit(X_new, y_new)

#    

y_pred = model.predict(X_new)

print(":", y_pred)

```

            .        (`X_initial`, `y_initial`)    `partial_fit`.    (`X_new`, `y_new`)           `partial_fit`.          .

  ,           ,        .

,   :

1.           (`SGDRegressor`).

2.        (`X_initial`, `y_initial`)    `partial_fit`.

3.     (`X_new`, `y_new`),            `partial_fit`.

4.          .

       ,             .

      ,            .              ,          . ,                   .

       ,     ,         .






 3:     



3.1   

         ,        .         ,          .



    ,          .      ,          .

    (DFS)                   .      ,            ,       .

  DFS               .            ,       ,            .

    DFS          .      ,      ,             .

 DFS    .  ,               -      .   ,        , DFS               .

    (BFS)      ,               .               .  ,      ,      ,         .

    BFS           ,           .       ,              .

 ,  BFS    .             ,          .  , BFS                .   ,        , BFS               .

         :

1.    (DFS):

 :          .

:  DFS             ,              .      ,      .

   DFS             Python   matplotlib      .   :

```python

import matplotlib.pyplot as plt

import numpy as np

#       

def visualize_maze(maze, path):

maze = np.array(maze)

path = np.array(path)

nrows, ncols = maze.shape

fig, ax = plt.subplots()

ax.imshow(maze, cmap=plt.cm.binary)

ax.plot(path[:, 1], path[:, 0], color='red', marker='o') #  

ax.plot(path[0][1], path[0][0], color='green', marker='o') #  

ax.plot(path[-1][1], path[-1][0], color='blue', marker='o') #  

ax.axis('image')

ax.set_xticks([])

ax.set_yticks([])

plt.show()

#          DFS

def dfs(maze, start, end, path=[]):

path = path + [start]

if start == end:

return path

if maze[start[0]][start[1]] == 1:

return None

for direction in [(0, 1), (1, 0), (0, -1), (-1, 0)]:

new_row, new_col = start[0] + direction[0], start[1] + direction[1]

if 0 <= new_row < len(maze) and 0 <= new_col < len(maze[0]):

if (new_row, new_col) not in path:

new_path = dfs(maze, (new_row, new_col), end, path)

if new_path:

return new_path

return None

#   (0  , 1  )

maze = [

[0, 1, 0, 0, 0],

[0, 1, 0, 1, 0],

[0, 0, 0, 1, 0],

[0, 1, 0, 1, 0],

[0, 0, 0, 0, 0]

]

start = (0, 0)

end = (4, 4)

#    

path = dfs(maze, start, end)

#  

visualize_maze(maze, path)

```

   ,  ,  0  ,  1  .  DFS           .      matplotlib,      ,         .






2.   (BFS):

 :             .

:  BFS         ,         .     ,       ,         ,      .

   BFS              Python.              `networkx`     .   :

```python

import networkx as nx

import matplotlib.pyplot as plt

from collections import deque

#       BFS

def bfs(graph, start, end):

visited = set()

queue = deque([(start, [start])]) #    

while queue:

current, path = queue.popleft()

if current == end:

return path

if current not in visited:

visited.add(current)

for neighbor in graph[current]:

if neighbor not in visited:

queue.append((neighbor, path + [neighbor]))

return None

#     (    )

road_network = {

'A': ['B', 'C'],

'B': ['A', 'D', 'E'],

'C': ['A', 'F'],

'D': ['B'],

'E': ['B', 'F'],

'F': ['C', 'E', 'G'],

'G': ['F']

}

start = 'A'

end = 'G'

#       

shortest_path = bfs(road_network, start, end)

print("  ", start, "", end, ":", shortest_path)

#     

G = nx.Graph()

for node in road_network:

G.add_node(node)

#    

for node, neighbors in road_network.items():

for neighbor in neighbors:

G.add_edge(node, neighbor)

#  

pos = nx.spring_layout(G) #    

nx.draw(G, pos, with_labels=True, node_color='lightblue', node_size=1000)

#   

shortest_path_edges = [(shortest_path[i], shortest_path[i + 1]) for i in range(len(shortest_path)  1)]

nx.draw_networkx_edges(G, pos, edgelist=shortest_path_edges, width=2, edge_color='red')

plt.title('       {}  {}'.format(start, end))

plt.show()

```

         ,     BFS         .      `matplotlib`.   ,      .










  ,            . DFS   ,      ,     BFS ,        .

       ,            .  ,     ,    A*  Dijkstra,            .





                   .          ,        ,     ,         .



  ()      ,      .    ,    ,       .            ,      .

       ,      .    ,              . ,     ,           .

       ,            .            ,      .   ,           ,          .

      ,             .       ,    ,   ,       .

,       .   ,         ,            ,        .

        .         ,    .            ,        .

      , ,         .       ,     ,         .

              `matplotlib`        .       Python,   :

```python

import matplotlib.pyplot as plt

import numpy as np

#     

def visualize_cutting(material_size, cut_pieces):

fig, ax = plt.subplots()

ax.set_aspect('equal')

#   

ax.add_patch(plt.Rectangle((0, 0), material_size[0], material_size[1], linewidth=1, edgecolor='black', facecolor='none'))

#   

for piece in cut_pieces:

ax.add_patch(plt.Rectangle((piece[0], piece[1]), piece[2], piece[3], linewidth=1, edgecolor='red', facecolor='none'))

plt.xlim(0, material_size[0])

plt.ylim(0, material_size[1])

plt.gca().set_aspect('equal', adjustable='box')

plt.xlabel('Width')

plt.ylabel('Height')

plt.title('Material Cutting Optimization')

plt.grid(True)

plt.show()

#     

material_size = (10, 10) #   

cut_pieces = [(1, 1, 3, 2), (5, 2, 4, 3), (2, 6, 2, 2)] #    

visualize_cutting(material_size, cut_pieces)

```

















          .     ,        .              .     ,              .

           .     ,     .         ,  ,   .



     (. Artificial Immune System, AIS)    ,     .     ,      ,    .

  AIS       .      AIS       .     ,    ,         .

  AIS     ,    .       ,    .     ,       .   ,      , ,  ,   , . ,  ,    ,       ,     .

            ,        ,   ,          .

       . ,    3   5 ,          ,          .            .

import numpy as np

import random

#      

def network_load(tasks_distribution):

return np.sum(tasks_distribution)

#         

def mutation(tasks_distribution):

mutated_tasks_distribution = tasks_distribution.copy()

server_index = np.random.randint(len(tasks_distribution))

task_index = np.random.randint(len(tasks_distribution[0]))

mutated_tasks_distribution[server_index][task_index] = np.random.randint(0, 100)

return mutated_tasks_distribution

def crossover(parent1, parent2):

child = parent1.copy()

for i in range(len(parent1)):

for j in range(len(parent1[0])):

if np.random.rand() > 0.5:

child[i][j] = parent2[i][j]

return child

def replace_worst_part(population, new_candidates):

fitness_values = [network_load(tasks_distribution) for tasks_distribution in population]

sorted_indices = np.argsort(fitness_values)

worst_part_indices = sorted_indices[-len(new_candidates):]

for i, index in enumerate(worst_part_indices):

population[index] = new_candidates[i]

return population

#     

num_servers = 3

num_tasks = 5

population_size = 10

num_generations = 100

#   

population = [np.random.randint(0, 100, (num_servers, num_tasks)) for _ in range(population_size)]

#    

for generation in range(num_generations):

#    

fitness_values = [network_load(tasks_distribution) for tasks_distribution in population]

#     

sorted_indices = np.argsort(fitness_values)

best_candidates = [population[i] for i in sorted_indices[:population_size // 2]]

#        

new_candidates = []

for _ in range(population_size // 2):

parent1 = random.choice(best_candidates)

parent2 = random.choice(best_candidates)

child = crossover(parent1, parent2)

if np.random.rand() < 0.5:

child = mutation(child)

new_candidates.append(child)

#       

population = replace_worst_part(population, new_candidates)

#   

best_solution = population[np.argmin([network_load(tasks_distribution) for tasks_distribution in population])]

print("  :", best_solution)

print(":", network_load(best_solution))

         ,         .

           ,        .       ,   ,    ,     .

,      :

```

  :

[[20 15 10 25 30]

[10 25 20 30 15]

[30 20 25 10 15]]

: 190

```

 ,        ,       .    ,       ,  190.




  .


   .

   ,     (https://www.litres.ru/book/dzheyd-karter/iskusstvennyy-intellekt-osnovnye-ponyatiya-70369546/chitat-onlayn/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


