Skip to content

Instantly share code, notes, and snippets.

View amansharma2910's full-sized avatar
🥳

Aman Sharma amansharma2910

🥳
View GitHub Profile
import java.util.Scanner;
import java.lang.String;
import java.util.ArrayList;
class arrival{
String name;
int id;
String address;
String time;
double fare;
@amansharma2910
amansharma2910 / blockchain.md
Created March 16, 2021 12:38
Buzzword topic for GWL
  • 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.
@amansharma2910
amansharma2910 / hello_world.py
Created March 15, 2021 15:59
A simple hello world program.
print("Hello world")
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)
# 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)
# 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)
# 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)
# 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)
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)
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)