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
// 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. |
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
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); |
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
// | |
// Created by hp on 05-01-2018. | |
// | |
#include <cstdlib> | |
#include "syncconsole.h" | |
#include "system.h" | |
static Semaphore *syncReadAvail; | |
static Semaphore *syncWriteDone; |
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
// 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. |
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
// | |
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); | |
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
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]!='.'): |
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 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() |
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
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 |
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
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) |
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 pandas as pd | |
import numpy as np | |
eps = np.finfo(float).eps | |
from sklearn.metrics import accuracy_score | |
from sklearn import preprocessing | |
import time | |
a = 1 | |
mu = 0.05 |