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 numpy as np | |
| import pandas as pd | |
| df = pd.read_csv('m_dataset.txt', header=None, names=['size', 'age', 'price']) | |
| df = (df - df.mean()) / df.std() | |
| df.insert(0, 'Ones', 1) | |
| cols = df.shape[1] | |
| X = np.matrix(df.iloc[:, 0:cols-1].values) |
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 numpy as np | |
| import pandas as pd | |
| df = pd.read_csv('dataset.txt', header=None) | |
| df.columns = ['size', 'price'] | |
| length = len(df['size']) | |
| for i in df.columns: | |
| df[i] = df[i] / max(df[i]) | |
| def linear_regression(theta_0, theta_1, dataset): |
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
| package com.company; | |
| import javax.script.ScriptEngineManager; | |
| import javax.script.ScriptEngine; | |
| public class Main { | |
| public static void main(String[] args) { | |
| String words = "24.2 + 2 - 1 * 10"; | |
| words = words.replaceAll(" ",""); |
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 urllib.request | |
| import pandas as pd | |
| from sklearn import svm | |
| def get_data(): | |
| page = urllib.request.urlopen("http://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data") | |
| data = page.read().decode("utf8") | |
| data_list = data.split("\n") | |
| data_file = open("car.txt","w") |
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 | |
| from sklearn import svm | |
| path = "C:/Users/codeboy101/Documents/Python Scripts/salary.txt" # set datafile path | |
| columns = ["age","workclass","fnlwgt","education","education-num","marital-status","occupation","relationship", | |
| "race","sex","capital-gain","capital-loss","hours-per-week","native-country","salary"] # custom column names | |
| get_data = pd.read_csv(path) | |
| df = pd.DataFrame(get_data) # load up dataframe |
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 makePretty(number): | |
| length = len(number) % 3 | |
| num_list = [i for i in number] | |
| if length == 0: | |
| get_num_list = execOp(2,3,num_list) | |
| elif length == 1: | |
| num_list.insert(1,",") | |
| rem_num_list = num_list[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
| from django.db import models | |
| from django.utils import timezone | |
| from datetime import date | |
| from django.contrib.auth.models import User | |
| class Story(models.Model): | |
| title = models.CharField(max_length=75) | |
| body = models.TextField() | |
| author = models.CharField(default="",max_length=75) | |
| pub_date = models.DateTimeField(default=timezone.now) |
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
| #models.py | |
| from django.db import models | |
| from django.contrib.auth.models import User | |
| class Story(models.Model): | |
| title = models.CharField(max_length=75) | |
| body = models.TextField() | |
| def __str__(self): | |
| return self.title |
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 django.db import models | |
| class Story(models.Model): | |
| title = models.CharField(max_length=75) | |
| body = models.TextField() | |
| rating = models.IntegerField(default=0) | |
| def __str__(self): | |
| return self.title |
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
| # frontPage view at last | |
| def login(request): | |
| form = LoginForm() | |
| if request.method == "POST": | |
| form = LoginForm(request.POST) | |
| if form.is_valid(): | |
| input_username = form.cleaned_data["username"] | |
| input_pass = form.cleaned_data["password"] | |
| try: | |
| user = authenticate(username=input_username,password=input_pass) |