# coding: utf-8 from __future__ import print_function, division, unicode_literals from toolz import pluck, compose from tabulate import tabulate from utility import csv_reader, Scaler, prepend_x0, dot import logistic_regression as logr import glm from out_utils import logistic_table from ml_util import train_test_split # Get the iris data set # SL: sepal length, SW: Sepal Width, PL: Petal Length, PW: Petal Width # 0: Iris Setosa 1: Iris Versicolour 2: Iris Virginica Z, q = csv_reader('./data/iris.csv', ['SL', 'SW', 'PL', 'PW'], 'Type') # Get Sepal Length and Petal Length features Zp = list(pluck([0, 2], Z)) # Get only the Iris Setosa (0) and Iris Versicolour (1) classes datap = [[f, o] for f, o in zip(Zp, q) if o != 2.0] Xp, yp = zip(*datap) y = list(yp) Xpp = [list(e) for e in Xp] print(Xpp) print(y) # Split set into training and testing data train_data, test_data = train_test_split(zip(Xpp, y), 0.33) # Scale the data X_train, y_train = zip(*train_data) scale = Scaler() scale.fit(X_train) transform = compose(prepend_x0, scale.transform)
# coding: utf-8 from __future__ import print_function, division, unicode_literals from functools import partial from toolz import compose, identity from tabulate import tabulate from utility import csv_reader, Scaler, prepend_x0 import metrics import linear_regression as lr import glm from ml_util import train_test_split import numpy as np from numpy.linalg import lstsq # Get the data Z, y = csv_reader('./data/Folds_small.csv', ['AT', 'V', 'AP', 'RH'], 'PE') data = zip(Z, y) # Split into a train set and test set train_data, test_data = train_test_split(data, 0.33) # Scale the training data scale = Scaler() Z_train, y_train = zip(*train_data) scale.fit(Z_train) transform = compose(prepend_x0, scale.transform) X_train = transform(Z_train) scaledtrain_data = zip(X_train, y_train) # Scale the testing data using the same scaling parameters # used for the training data Z_test, y_test = zip(*test_data) X_test = transform(Z_test) h_theta0 = [0., 0., 0., 0., 0.]
import random import numpy as np import matplotlib.pyplot as plt import glm import logreg as lr from utility import csv_reader, Scaler from ml_util import train_test_split, encode_labels from out_utils import logistic_table from metrics import MScores # Get the iris data set # SL: sepal length, SW: Sepal Width, PL: Petal Length, PW: Petal Width # 0: Iris Setosa 1: Iris Versicolour 2: Iris Virginica Z, q = csv_reader('./data/iris.csv', ['SL', 'SW', 'PL', 'PW'], 'Type') t = list(zip(Z, q)) random.shuffle(t) W, u = list(zip(*t)) yencoded = encode_labels(np.array(u), 3) train_data, test_data = train_test_split(zip(W, yencoded), 0.33) # Scale data Z_train, y_train = zip(*train_data) y_train = np.array(y_train) scale = Scaler() scale.fit(Z_train) scaledX_train = scale.transform(Z_train) Z_test, y_test = zip(*test_data) y_test = np.array(y_test) scaledX_test = scale.transform(Z_test)
2) checks over related cells 3) yeets values in anyway """ print(grid) check_possible_values(grid) compare_related_cells(grid) quasi_guess(grid) if not solved(grid): print("couldn't completely solve Sudoku") else: print("Solved") print(grid) return # use a decorator for this? def sudoku_solver(grid, time_it=True): if time: start = time() solve() if time: dt = time() - start print("time taken = ", dt, "seconds") return if __name__ == "__main__": grid = csv_reader(argv[1]) this_sudoku = SudokuGrid(grid) solve(this_sudoku)