Skip to content

Instantly share code, notes, and snippets.

View ajoydas's full-sized avatar

Ajoy Das ajoydas

View GitHub Profile
def pocket_perceptron(weights, binary_train, binary_test):
best_weights = weights
best_accuracy = 0
count = 0
K = 100
k = 0
while True:
# print(weights)
for row in binary_train:
predicted = predict(row, weights)
w = [0.0 for i in range(len(binary_train[0])-2)]
w.append(1.0)
weights = w.copy()
# Make a prediction with weights
def predict(row, weights):
activation = 0
for i in range(len(weights)-1):
activation += weights[i] * row[i]
return 1 if activation >= 0.0 else 2
import pandas as pd
import numpy as np
df3 = pd.read_csv('datasets/CustomerChurn.csv')
df3 = df3.drop('customerID', axis=1)
df3 = df3.replace(r'^\s+$', np.nan, regex=True)
df3['TotalCharges'] = df3['TotalCharges'].astype(float)
df3 = df3.fillna(df3.mean())
df3.isnull().values.any()
ins_count = 0
tstate_count = 0
df = pd.DataFrame()
position= []
address = []
is_first = False
with open('in.txt') as infile:
for line in infile:
if(line[0]!='.'):
@ajoydas
ajoydas / address.cc
Created January 18, 2018 08:49 — forked from Yeaseen/address.cc
//
void AddrSpace::loadIntoFreePage(int vpn){
int physicalPageNo=memoryManager->AllocPage();
pageTable[vpn].physicalPage = physicalPageNo;
pageTable[vpn].valid = true;
bzero(&machine -> mainMemory[(pageTable[vpn].physicalPage) * PageSize], PageSize);
// exception.cc
// Entry point into the Nachos kernel from user programs.
// There are two kinds of things that can cause control to
// transfer back to here from user code:
//
// syscall -- The user code explicitly requests to call a procedure
// in the Nachos kernel. Right now, the only function we support is
// "Halt".
//
// exceptions -- The user code does something that the CPU can't handle.
//
// Created by hp on 05-01-2018.
//
#include <cstdlib>
#include "syncconsole.h"
#include "system.h"
static Semaphore *syncReadAvail;
static Semaphore *syncWriteDone;
private void setupTabs() {
mTabHost = (MaterialTabHost) findViewById(R.id.materialTabHost);
mPager = (ViewPager) findViewById(R.id.viewPager);
mAdapter = new ViewPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mAdapter);
//when the page changes in the ViewPager, update the Tabs accordingly
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
mTabHost.setSelectedNavigationItem(position);
// threadtest.cc
// Simple test case for the threads assignment.
//
// Create two threads, and have them context switch
// back and forth between themselves by calling Thread::Yield,
// to illustratethe inner workings of the thread system.
//
// Copyright (c) 1992-1993 The Regents of the University of California.
// All rights reserved. See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.
@ajoydas
ajoydas / ns2-olsr-ubuntu-xenial.md
Created November 30, 2017 22:26 — forked from slashsbin/ns2-olsr-ubuntu-xenial.md
Install & Setup NS2(w/ UM-OLSR Patch) on Ubuntu 16.04

Upgrade Ubuntu

sudo apt update
sudo apt upgrade -Vy

Download NS2

Download NS2 & OLSR: