- Blockchain is a specific type of database.
- It differs from a typical database in the way it stores information; blockchains store data in blocks that are then chained together.
- As new data comes in it is entered into a fresh block. Once the block is filled with data it is chained onto the previous block, which makes the data chained together in chronological order.
- Different types of information can be stored on a blockchain but the most common use so far has been as a ledger for transactions.
- In Bitcoin’s case, blockchain is used in a decentralized way so that no single person or group has control—rather, all users collectively retain control.
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.util.Scanner; | |
| import java.lang.String; | |
| import java.util.ArrayList; | |
| class arrival{ | |
| String name; | |
| int id; | |
| String address; | |
| String time; | |
| double fare; | 
  
    
      This file contains hidden or 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
    
  
  
    
  | print("Hello world") | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| import torchblaze.mltests as mls | |
| # creating an exemplary model class | |
| class Net(nn.Module): | |
| def __init__(self): | |
| super(Net, self).__init__() | |
| self.conv1 = nn.Conv2d(3, 6, 5) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | # step-1: importing model class from sklearn | |
| from sklearn.cluster import AgglomerativeClustering | |
| # step-2: creating model class object; n_clusters denotes the number of clusters to find | |
| model = AgglomerativeClustering(n_clusters = 3) | |
| # step-3: fitting training data and then predicting cluster index for each data instance | |
| model.fit_predict(X) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | # step-1: importing model class from sklearn | |
| from sklearn.cluster import DBSCAN | |
| # step-2: creating model class object | |
| # eps- max. distance between two samples to be considered neighborhs (default = 0.5) | |
| # min_samples- The number of samples in a neighborhood for a point to be considered as a core point (default = 5) | |
| model = DBSCAN(eps = 1.5, min_samples = 6) | |
| # step-3: fitting training data and then predicting cluster index for each data instance | |
| model.fit_predict(X) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | # step-1: importing model class from sklearn | |
| from sklearn.cluster import KMeans | |
| # step-2: creating model class object; n_clusters denotes number of assumed clusters | |
| model = KMeans(n_clusters = 5) | |
| # step-3: fitting training data and then predicting cluster index for each data instance | |
| model.fit_predict(X) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | # running inference for k=8 | |
| test_predictions = KNNClassifier(X_train, y_train, X_test, k = 8) | |
| # checking the accuracy | |
| acc = accuracy(y_test, test_predictions) | |
| print('Model accuracy (k = 8) = ', acc*100) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | k_values = list(range(1,20)) | |
| accuracy_list = [] | |
| for k in k_values: | |
| test_predictions = KNNClassifier(X_train, y_train, X_test, k) | |
| accuracy_list.append(accuracy(y_test, test_predictions)) | |
| # plotting k-value vs accuracy plot | |
| sns.barplot(k_values, accuracy_list) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | from sklearn.neighbors import KNeighborsClassifier as KNN | |
| model = KNN() | |
| model.fit(X_train, y_train) | |
| preds = model.predict(X_test) | |
| acc = accuracy(y_test, preds) | |
| print('Model accuracy (Sklearn) = ', acc*100) | 
NewerOlder