Advertisement
varun1729

Untitled

Dec 27th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 16.55 KB | None | 0 0
  1. FIND S
  2.  
  3. import csv
  4. import random
  5. a=[[]]
  6. with open("finds.csv",'r') as CSVFile:
  7.   reader=csv.reader(CSVFile)
  8.   for row in reader:
  9.     a.append(row)
  10. print(a)
  11. fs=['0']*(len(a[1])-1)
  12. print(fs)
  13.  
  14. rlen=len(a)
  15. for i in range(0,rlen):
  16.   alen=len(a[i])
  17.   if alen == 0:
  18.     continue
  19.   elif a[i][alen-1] == 'Yes':
  20.     for j in range(0,alen-1):
  21.       if fs[j]=='0':
  22.         fs[j]=a[i][j]
  23.       elif fs[j]=='?':
  24.         continue
  25.       elif fs[j] != a[i][j]:
  26.         fs[j]='?'
  27.       else:
  28.         fs[j]=a[i][j]
  29.     print(fs)
  30. print(fs)
  31.  
  32. KNN
  33.  
  34. import csv
  35. import math
  36. A = []
  37. with open('iris.csv','r') as csvfile:
  38.   for row in csv.reader(csvfile):
  39.     A.append(row)
  40. ints = A[1:]
  41. testSet = [7.2,3.6,5.1,2.5]
  42. def ED(d1,d2,length):
  43.   distance = 0
  44.   for x in range(length):
  45.     distance += (float(d1[x])-d2[x])*(float(d1[x])-d2[x])
  46.   return math.sqrt(distance)
  47.  
  48. def KNN(trainSet, testset, k):
  49.   ll = []
  50.   for x in trainSet:
  51.     ll.append([ED(x,testSet,len(testSet)),x[len(x)-1]])
  52.   ll.sort(key=lambda x: int(x[0]))
  53.   ss = ll[:k]
  54.   se = list(set([x[1] for x in ss]))
  55.   ss = [x[1] for x in ss]
  56.   x = [0]*len(se)
  57.   for i in range(len(se)):
  58.     x[i] = ss.count(se[i])
  59.   typ = se[x.index(max(x))]
  60.   return typ
  61.  
  62.  
  63. t = KNN(ints,testSet,13)
  64. print('The estimated value of testSet is: ',t)
  65.  
  66. BFS,DFS,IDDFS,DLS
  67. #BFS, DFS, DLS, IDDFS
  68. graph={
  69.     0:[1,2],
  70.     1:[3,4],
  71.     2:[5,6],
  72.     3:[],
  73.     4:[],
  74.     5:[],
  75.     6:[]
  76. }
  77. visited=[]
  78. queue=[]
  79. def bfs(visited,graph,node):
  80.   visited.append(node)
  81.   queue.append(node)
  82.   while queue:
  83.     s=queue.pop(0)
  84.     print(s,end=' ')
  85.     for neighbour in graph[s]:
  86.       if neighbour not in visited:
  87.         visited.append(neighbour)
  88.         queue.append(neighbour)
  89.    
  90. print('BFS Traversal')
  91. bfs(visited,graph,0)
  92. print()
  93.  
  94. visited=set()
  95. def DFS(visited,graph,node):
  96.   if node not in visited:
  97.     visited.add(node)
  98.     print(node)
  99.     for neighbour in graph[node]:
  100.       dfs(visited,graph,neighbour)
  101.  
  102. print('DFS Traversal')
  103. DFS(visited,graph,0)
  104.  
  105. visited=set()
  106. limit=1
  107. def DLS(visited,graph,node,k):
  108.   if node not in visited:
  109.     if(k<=l):
  110.       visited.add(node)
  111.       print(node)
  112.       for neighbour in graph[node]:
  113.         DLS(visited,graph,neighbour,k+1)
  114.  
  115. print('DLS Traversal')
  116. DLS(visited,graph,0,0)
  117.  
  118. def IDDFS(visited,graph,node,k,l):
  119.   if node not in visited:
  120.     if(k<=l):
  121.       visited.add(node)
  122.       print(node)
  123.       for neighbour in graph[node]:
  124.         IDDFS(visited,graph,neighbour,k+1,l)
  125.  
  126. print('IDDFS Traversal')
  127. for i in range(3):
  128.   visited=set()
  129.   IDDFS(visited,graph,0,0,i)
  130.  
  131.  
  132. WATER JUG
  133. from collections import defaultdict
  134. jug1, jug2, aim = 4,2,1
  135. visited = defaultdict(lambda: False)
  136. def waterJugSolver(amt1, amt2):
  137.    if (amt1 == aim and amt2 == 0) or (amt2 == aim and amt1 == 0):
  138.       print(amt1, amt2)
  139.       return True
  140.    if visited[(amt1, amt2)] == False:
  141.       print(amt1, amt2)
  142.       visited[(amt1, amt2)] = True
  143.       return (waterJugSolver(0, amt2) or
  144.             waterJugSolver(amt1, 0) or
  145.             waterJugSolver(jug1, amt2) or
  146.             waterJugSolver(amt1, jug2) or
  147.             waterJugSolver(amt1 + min(amt2, (jug1-amt1)), amt2 - min(amt2, (jug1-amt1))) or
  148.             waterJugSolver(amt1 - min(amt1, (jug2-amt2)),amt2 + min(amt1, (jug2-amt2))))
  149.    else:
  150.       return False
  151.  
  152. print("Steps: ")
  153.  
  154. waterJugSolver(0, 0)
  155.  
  156. N QUEEN
  157. global N
  158. N = 4
  159. def printSolution(board):
  160.     for i in range(N):
  161.         for j in range(N):
  162.             print (board[i][j],end=' ')
  163.         print()
  164.  
  165. def isSafe(board, row, col):
  166.     for i in range(col):
  167.         if board[row][i] == 1:
  168.             return False
  169.     for i, j in zip(range(row, -1, -1), range(col, -1, -1)):
  170.         if board[i][j] == 1:
  171.             return False
  172.     for i, j in zip(range(row, N, 1), range(col, -1, -1)):
  173.         if board[i][j] == 1:
  174.             return False
  175.  
  176.     return True
  177.  
  178. def solveNQUtil(board, col):
  179.     if col >= N:
  180.         return True
  181.     for i in range(N):
  182.         if isSafe(board, i, col):
  183.             board[i][col] = 1
  184.             if solveNQUtil(board, col + 1) == True:
  185.                 return True
  186.             board[i][col] = 0
  187.     return False
  188.  
  189. def solveNQ():
  190.     board = [ [0, 0, 0, 0],
  191.             [0, 0, 0, 0],
  192.             [0, 0, 0, 0],
  193.             [0, 0, 0, 0] ]
  194.     if solveNQUtil(board, 0) == False:
  195.         print ("Solution does not exist")
  196.         return False
  197.     printSolution(board)
  198.     return True
  199. solveNQ()
  200.  
  201. ALPHA BETAA
  202.  
  203. MAX, MIN = 1000, -1000
  204.  
  205. def minimax(depth, nodeIndex, maximizingPlayer, values, alpha, beta):
  206.     if depth == 3:
  207.         print(values[nodeIndex])
  208.         return values[nodeIndex]
  209.     if maximizingPlayer:
  210.         best = MIN
  211.         for i in range(0, 2):
  212.             val = minimax(depth + 1, nodeIndex * 2 + i, False, values, alpha, beta)
  213.             best = max(best, val)
  214.             alpha = max(alpha, best)
  215.             if beta <= alpha:
  216.                 break
  217.         return best
  218.     else:
  219.         best = MAX
  220.         for i in range(0, 2):
  221.             val = minimax(depth + 1, nodeIndex * 2 + i, True, values, alpha, beta)
  222.             best = min(best, val)
  223.             beta = min(beta, best)
  224.             if beta <= alpha:
  225.                 break
  226.         return best
  227.    
  228. values = [3, 5, 6, 9, 1, 2, 0, -1]
  229. print("The optimal value is :", minimax(0, 0, True, values, MIN, MAX))
  230.  
  231. TIC TAC TOE
  232.  
  233. player, opponent = 'x', 'o'
  234.  
  235.  
  236. def isMovesLeft(board):
  237.     for i in range(3):
  238.         for j in range(3):
  239.             if (board[i][j] == '_'):
  240.                 return True
  241.     return False
  242.  
  243.  
  244. def evaluate(b):
  245.     for row in range(3):
  246.         if (b[row][0] == b[row][1] and b[row][1] == b[row][2]):
  247.             if (b[row][0] == player):
  248.                 return 10
  249.             elif (b[row][0] == opponent):
  250.                 return -10
  251.     for col in range(3):
  252.  
  253.         if (b[0][col] == b[1][col] and b[1][col] == b[2][col]):
  254.  
  255.             if (b[0][col] == player):
  256.                 return 10
  257.             elif (b[0][col] == opponent):
  258.                 return -10
  259.     if (b[0][0] == b[1][1] and b[1][1] == b[2][2]):
  260.  
  261.         if (b[0][0] == player):
  262.             return 10
  263.         elif (b[0][0] == opponent):
  264.             return -10
  265.  
  266.     if (b[0][2] == b[1][1] and b[1][1] == b[2][0]):
  267.  
  268.         if (b[0][2] == player):
  269.             return 10
  270.         elif (b[0][2] == opponent):
  271.             return -10
  272.     return 0
  273.  
  274.  
  275. def minimax(board, depth, isMax):
  276.     score = evaluate(board)
  277.     if (score == 10):
  278.         return score
  279.     if (score == -10):
  280.         return score
  281.     if (isMovesLeft(board) == False):
  282.         return 0
  283.     if (isMax):
  284.         best = -1000
  285.         for i in range(3):
  286.             for j in range(3):
  287.                 if (board[i][j] == '_'):
  288.                     board[i][j] = player
  289.                     best = max(best, minimax(board,
  290.                                              depth + 1,
  291.                                              not isMax))
  292.                     board[i][j] = '_'
  293.         return best
  294.     else:
  295.         best = 1000
  296.         for i in range(3):
  297.             for j in range(3):
  298.                 if (board[i][j] == '_'):
  299.                     board[i][j] = opponent
  300.                     best = min(best, minimax(board, depth + 1, not isMax))
  301.                     board[i][j] = '_'
  302.         return best
  303.  
  304.  
  305. def findBestMove(board):
  306.     bestVal = -1000
  307.     bestMove = (-1, -1)
  308.     for i in range(3):
  309.         for j in range(3):
  310.  
  311.             if (board[i][j] == '_'):
  312.                 board[i][j] = player
  313.                 moveVal = minimax(board, 0, False)
  314.  
  315.                 # Undo the move
  316.                 board[i][j] = '_'
  317.                 if (moveVal > bestVal):
  318.                     bestMove = (i, j)
  319.                     bestVal = moveVal
  320.  
  321.     print("The value of the best Move is :", bestVal)
  322.     print()
  323.     return bestMove
  324.  
  325.  
  326. board = [
  327.     ['x', 'o', 'x'],
  328.     ['o', 'o', 'x'],
  329.     ['_', '_', '_']
  330. ]
  331.  
  332. bestMove = findBestMove(board)
  333.  
  334. print("The Optimal Move is :")
  335. print("ROW:", bestMove[0], " COL:", bestMove[1])
  336.  
  337. K MEANS
  338.  
  339. from operator import itemgetter
  340. import numpy
  341. import random
  342. from sklearn import datasets
  343. import matplotlib.pyplot as plt
  344.  
  345. def newcent(clus):
  346.     a=0
  347.     b=0
  348.     n=len(clus)
  349.     for i in range(n):
  350.         a=a+clus[i][0]
  351.         b=b+clus[i][1]
  352.     return [a/n,b/n]
  353.  
  354. def eucdist(p1,p2):
  355.     return ((p2[0]-p1[0])**2+(p2[1]-p1[1])**2)**(0.5)
  356.  
  357. def getmin(a,b,c):
  358.     if(a<=b and a<=c):
  359.       return 1
  360.     elif(b<=a and b<=c):
  361.       return 2
  362.     else:
  363.       return 3
  364.  
  365. iris=datasets.load_iris()
  366. data=list(iris.data)
  367. target=list(iris.target)
  368. n=len(target)
  369.  
  370. for i in range(n):
  371.     data[i]=list(data[i])
  372.  
  373. newattr=[]
  374. for i in range(n):
  375.     newattr.append(data[i][0:2])
  376.  
  377. k1=random.choice(newattr)
  378. k2=random.choice(newattr)
  379. k3=random.choice(newattr)
  380. # print(k1,k2,k3)
  381. newattr.remove(k1)
  382. newattr.remove(k2)
  383. newattr.remove(k3)
  384.  
  385. n=len(newattr)
  386. c1=[k1]
  387. c2=[k2]
  388. c3=[k3]
  389. for i in range(n):
  390.     clusno=getmin(eucdist(newattr[i],k1),eucdist(newattr[i],k2),eucdist(newattr[i],k3))
  391.     if(clusno==1):
  392.         c1.append(newattr[i])
  393.         k1=newcent(c1)
  394.     elif(clusno==2):
  395.         c2.append(newattr[i])
  396.         k2=newcent(c2)
  397.     elif(clusno==3):
  398.         c3.append(newattr[i])
  399.         k3=newcent(c3)
  400. # print(k1,k2,k3)
  401. xcor=[]
  402. ycor=[]
  403. for i in range(len(c1)):
  404.     xcor.append(c1[i][0])
  405.     ycor.append(c1[i][1])
  406. plt.scatter(xcor,ycor,c='g',marker='o')
  407.  
  408. xcor=[]
  409. ycor=[]
  410. for i in range(len(c2)):
  411.     xcor.append(c2[i][0])
  412.     ycor.append(c2[i][1])
  413. plt.scatter(xcor,ycor,c='r',marker='o')
  414.  
  415. xcor=[]
  416. ycor=[]
  417. for i in range(len(c3)):
  418.     xcor.append(c3[i][0])
  419.     ycor.append(c3[i][1])
  420. plt.scatter(xcor,ycor,c='y',marker='o')
  421.  
  422.  
  423. EM
  424.  
  425. from sklearn import datasets
  426. import pandas as pd
  427. import numpy as np
  428. import matplotlib.pyplot as plt
  429.  
  430. iris=datasets.load_iris()
  431. X=pd.DataFrame(iris.data)
  432. X.columns=['Sepal_Length','Sepal_Width','Petal_Length','Petal_Width']
  433. Y=pd.DataFrame(iris.target)
  434. Y.columns=['Targets']
  435.  
  436. colormap=np.array(['red','lime','blue'])
  437. plt.figure(figsize=(7,10))
  438. plt.subplot(2,1,1)
  439. plt.scatter(X.Sepal_Length,X.Sepal_Width,c=colormap[Y.Targets],s=40)
  440. plt.xlabel('Sepal Length')
  441. plt.ylabel('Sepal Width')
  442. plt.title('Real Clusters')
  443.  
  444. from sklearn import preprocessing
  445. scaler=preprocessing.StandardScaler()
  446. scaler.fit(X)
  447. xsa=scaler.transform(X)
  448. xs=pd.DataFrame(xsa,columns=X.columns)
  449.  
  450. from sklearn.mixture import GaussianMixture
  451. gmm=GaussianMixture(n_components=3)
  452. gmm.fit(xs)
  453. gmm_y=gmm.predict(xs)
  454.  
  455. plt.subplot(2,1,2)
  456. plt.scatter(X.Sepal_Length,X.Sepal_Width,c=colormap[gmm_y],s=40)
  457. plt.title("GMM Clusters")
  458. plt.xlabel('Sepal Length')
  459. plt.ylabel('Sepal Width')
  460.  
  461.  
  462. AND PERCEPTRON
  463.  
  464. import numpy as np
  465. import random as r
  466.  
  467. inputs = np.array([[0,0,1,1],[0,1,0,1]])
  468. preds = np.array([0,0,0,1])
  469. weights = np.array([r.uniform(-0.5,0.5),r.uniform(-0.5,0.5)])
  470.  
  471. print(weights)
  472.  
  473. actual = []
  474. errors = []
  475. j = 0
  476. threshold = 0
  477. for i in range(len(preds)):
  478.   k = inputs[0][j]*weights[0] +weights[1] *inputs[1][j]
  479.   if  k > threshold:
  480.      actual.append(1)
  481.   else:
  482.      actual.append(0)
  483.   errors.append(preds[i]-actual[i])
  484.   j+=1
  485. print('Predicted',preds)
  486. print('Actual',actual)
  487. print('Errors',errors)
  488.  
  489.  
  490. OR PERCEPTRON
  491.  same as and
  492.  
  493. PERCEPTRON
  494.  
  495. import numpy as np
  496. import random as r
  497. import math
  498.  
  499. def af(x):
  500.   return (1/(1+math.exp(-x)))
  501.  
  502. inputs = np.array([0,1,0])
  503. preds = np.array([1])
  504. weights = np.array([r.uniform(-0.5,0.5),r.uniform(-0.5,0.5),r.uniform(-0.5,0.5)])
  505. print(weights)
  506.  
  507. actual = []
  508. errors = []
  509. bias = r.uniform(-0.5,0.5)
  510.  
  511. k =0
  512. for i in range(len(inputs)):
  513.   k += inputs[i] * weights[i]
  514. k+= bias
  515. print('Net = ',k)
  516. k = af(k)
  517. print('Actual (After Activation)  = ',k)
  518. actual.append(k)
  519. errors.append((preds[0] - actual[0]))
  520.  
  521. print('Predicted',preds)
  522. print('Actual',actual)
  523. print('Errors',errors)
  524.  
  525.  
  526. a* algorithm
  527.  
  528. def aStarAlgo(start_node, stop_node):
  529.     open_set = set(start_node)
  530.     closed_set = set()
  531.  
  532.     g = {}              
  533.     parents = {}
  534.  
  535.     g[start_node] = 0
  536.     parents[start_node] = start_node
  537.     while len(open_set) > 0:
  538.         n = None
  539.         for v in open_set:
  540.             if n == None or g[v] + heuristic(v) < g[n] + heuristic(n):
  541.                 n = v
  542.         if n == stop_node or Graph_nodes[n] == None:
  543.             pass
  544.         else:
  545.             for (m, weight) in get_neighbors(n):
  546.                 if m not in open_set and m not in closed_set:
  547.                     open_set.add(m)
  548.                     parents[m] = n
  549.                     g[m] = g[n] + weight
  550.                 else:
  551.                     if g[m] > g[n] + weight:
  552.                         g[m] = g[n] + weight
  553.                         parents[m] = n
  554.                         if m in closed_set:
  555.                             closed_set.remove(m)
  556.                             open_set.add(m)
  557.         if n == None:
  558.             print('Path does not exist!')
  559.             return None
  560.  
  561.         if n == stop_node:
  562.             path = []
  563.             while parents[n] != n:
  564.                 path.append(n)
  565.                 n = parents[n]
  566.             path.append(start_node)
  567.             path.reverse()
  568.             print("Path found: " + str(path))
  569.             return path
  570.         open_set.remove(n)
  571.         closed_set.add(n)
  572.     print('Path does not exist!')
  573.     return None
  574.  
  575. def get_neighbors(v):
  576.     if v in Graph_nodes:
  577.         return Graph_nodes[v]
  578.     else:
  579.         return None
  580.  
  581. def heuristic(n):
  582.     H_dist = {
  583.         'A': 11,
  584.         'B': 6,
  585.         'C': 5,
  586.         'D': 7,
  587.         'E': 3,
  588.         'F': 6,
  589.         'G': 5,
  590.         'H': 3,
  591.         'I': 1,
  592.         'J': 0
  593.     }
  594.     return H_dist[n]
  595.  
  596. Graph_nodes = {
  597.     'A': [('B', 6), ('F', 3)],
  598.     'B': [('A', 6), ('C', 3), ('D', 2)],
  599.     'C': [('B', 3), ('D', 1), ('E', 5)],
  600.     'D': [('B', 2), ('C', 1), ('E', 8)],
  601.     'E': [('C', 5), ('D', 8), ('I', 5), ('J', 5)],
  602.     'F': [('A', 3), ('G', 1), ('H', 7)],
  603.     'G': [('F', 1), ('I', 3)],
  604.     'H': [('F', 7), ('I', 2)],
  605.     'I': [('E', 5), ('G', 3), ('H', 2), ('J', 3)],
  606. }
  607.  
  608. aStarAlgo('A', 'J')
  609.  
  610.  
  611. BACK PROP
  612.  
  613. targets = [0.01,0.99]
  614. inputs = [0.05,0.10]
  615. weights = [[0.15,0.20],[0.25,0.30],[0.40,0.45],[0.50,0.55]]
  616. biases = [0.35,0.60]
  617. neth = [0,0]
  618. outh = [0,0]
  619. neto =[0,0]
  620. outo = [0,0]
  621. delta = [0,0]
  622. whk = [0,0]
  623. import math
  624. learning_rate = 0.5
  625. def forward():
  626.   for i in range(0,2):
  627.     netval = 0
  628.     k = 0
  629.     for j in weights[i]:
  630.       netval += j*inputs[k]
  631.       k+=1
  632.     netval += biases[0]
  633.     neth[i] = netval
  634.     netval = 1/(1+math.exp(-netval))
  635.     outh[i] = netval
  636.   global ak
  637.   ak =i
  638.   i+=1
  639.   m = 0
  640.   while(i < ak+1+len(outh)):
  641.     netval = 0
  642. k = 0
  643.     for j in weights[i]:
  644.       netval +=j*outh[k]
  645.       k+=1
  646.     netval += biases[1]
  647.     neto[m] = netval
  648.     netval = 1/(1+math.exp(-netval))
  649.     outo[m] = netval
  650.     m+=1
  651.     i+=1
  652.   i= 0
  653.  
  654. def get_error():
  655.   sum = 0
  656.   for i in range(len(outo)):
  657.     dif = targets[i] - outo[i]
  658.     sum +=dif**2
  659.   return sum/2
  660.  
  661. def outputlayer():
  662.   for i in range(0,len(outo)):
  663.     delt = -(targets[i] - outo[i])*(outo[i])*(1-outo[i])
  664.     delta[i] = (delt)
  665.  
  666.   i = ak
  667.   k = 0
  668.   for i in range(ak+1,ak+1+len(outo)):
  669.     for j in range(len(outo)):
  670.       newval = weights[i][j] - learning_rate *(delta[k] * outh[k])
  671.       weights[i][j] = newval
  672.     k+=1
  673.  
  674.  
  675. def hiddenlayers():
  676.   for i in range(0,len(outh)):
  677.     net = outh[i]*(1-outh[i])
  678.     val = net
  679.  
  680.   for j in range(0,len(outh)):
  681.     val = val * inputs[i] * whk[i]
  682.     newval = weights[i][j] - learning_rate*val
  683.     weights[i][j] = newval
  684.  
  685. print('Initially weights : ',weights)
  686.  
  687. for i in range(0,5):
  688.   print('Epoch ',i+1)
  689.  
  690. forward()
  691. outputlayer()
  692. hiddenlayers()
  693. print('Error :',get_error())
  694. print('Weights: ',weights)
  695.  
  696.  
  697. LOCALLY WEIGHTED
  698. import csv,math,operator
  699. A=[]
  700. with open('tips (1).csv',newline='') as csvfile:
  701.   next(csvfile)
  702.   for row in csv.reader(csvfile):
  703.     A.append(row)
  704. import numpy as np
  705. import pandas as pd
  706. import matplotlib.pyplot as plt
  707. def kernel(point, xmat, k):
  708.   m,n = np.shape(xmat)
  709.   weights = np.mat(np.eye((m)))
  710.   for j in range(m):
  711.     diff = point - X[j]
  712.     weights[j, j] = np.exp(diff * diff.T / (-2.0 * k**2))
  713.   return weights
  714. def localWeight(point, xmat, ymat, k):
  715.   wt = kernel(point, xmat, k)
  716.   W = (X.T * (wt*X)).I * (X.T * wt * ymat.T)
  717.   return W
  718. def localWeightedRegression(xmat, ymat, k):
  719.   m,n = np.shape(xmat)
  720.   ypred = np.zeros(m)
  721.   for i in range(m):
  722.     ypred[i] = xmat[i] * localWeight(xmat[i], xmat, ymat, k)
  723.   return ypred
  724. df = pd.read_csv('tips (1).csv')
  725. colA = np.array(df.total_bill)
  726. colB = np.array(df.tip)
  727. mcolA = np.mat(colA)
  728. mcolB = np.mat(colB)
  729. m = np.shape(mcolB)[1]
  730. one = np.ones((1, m), dtype = int)
  731. X = np.hstack((one.T, mcolA.T))
  732. print(X.shape)
  733. ypred = localWeightedRegression(X, mcolB, 0.8)
  734. xsort = X.copy()
  735. xsort.sort(axis = 0)
  736. plt.scatter(colA, colB, color = 'blue')
  737. plt.plot(xsort[:,1], ypred[X[:,1].argsort(0)], color = 'yellow', linewidth=5)
  738. plt.xlabel('Total Bill')
  739. plt.ylabel('Tip')
  740. plt.show()
  741.  
  742.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement