Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions challenges/week_1/checker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import bus_fare_challenge
import bus_fare_challenge as solution
import datetime
import unittest

Expand All @@ -12,7 +12,7 @@ def setUp(self) -> None:
"Tue": 100,
"Wed": 100,
"Thu": 100,
"Thu": 100,
"Fri": 100,
"Sat": 60,
"Sun": 80,
}
Expand All @@ -22,15 +22,15 @@ def test_date(self) -> None:
Tests whether the date returned by the program is correct.
"""
actual = self.date
given = bus_fare_challenge.date
given = solution.date
self.assertEqual(actual, given, f"Today's date is Wrong by {given - actual}!")

def test_day(self) -> None:
"""
Tests whether the day returned by the program is correct.
"""
actual = self.day
given = bus_fare_challenge.day
given = solution.day
self.assertEqual(
actual, given, f"Today is wrong, expexted {actual} but got {given}!"
)
Expand All @@ -40,7 +40,7 @@ def test_fare(self) -> None:
Tests whether the fare returned by the program is correct.
"""
actual = self.charts[self.day]
given = bus_fare_challenge.fare
given = solution.fare
self.assertEqual(
actual, given, f"Fare is wrong, expected {actual} but got {given}!"
)
Expand Down
62 changes: 62 additions & 0 deletions challenges/week_5/checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import unittest
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn import metrics
import linear_regression_solution as solution


class TestLinearRegressionChallenge(unittest.TestCase):
def setUp(self) -> None:
self.df = pd.read_csv(
"/home/tim/Dev/DS/Learning/python-bootcamp/challenges/week_5/data.csv",
index_col=0,
)
self.X = np.array(self.df.dropna()["x"]).reshape(-1, 1)
self.y = np.array(self.df.dropna()["y"]).reshape(-1, 1)
self.performance = solution.performance

def test_prep_data(self) -> None:
actual = self.df.dropna().size
given = solution.clean_data.size
self.assertEqual(
actual,
given,
f"Expected {actual} but got {given}. Please clean your data off null values!",
)

def test_feature_shape(self) -> None:
actual = (970, 1)
given = solution.X.shape
self.assertEqual(
actual,
given,
f"Expected {actual} but got {given}. Please reshape your features!",
)
given = solution.y.shape
self.assertEqual(
actual,
given,
f"Expected {actual} but got {given}. Please reshape your features!",
)

def test_model_evaluation(self) -> None:
actual_type = tuple
given_type = type(solution.performance)
self.assertEqual(
actual_type,
given_type,
f"Expected {actual_type} but got {given_type}. Model evaluation fuction should return a tuple!",
)


if __name__ == "__main__":

print("=========================================================================")
print("=========================================================================")
print("===== Start: Checking ********************************************* =====")
unittest.main(exit=False)
print("===== End: Checking ********************************************* =======")
print("=========================================================================")
Loading