Skip to content
Snippets Groups Projects
Commit cf46fb55 authored by bjje's avatar bjje
Browse files

Minor bug fixes

parent 822fecb6
Branches
Tags
No related merge requests found
"""
This is a helper function which can help you debug the Python installation
v20240125
"""
import os
import sklearn
......@@ -13,12 +16,18 @@ print('Current working directory {}.'.format(pathlib.Path().resolve()))
print('')
print('The numpy version is {}.'.format(np.__version__))
print('The scikit-learn version is {}.'.format(sklearn.__version__))
print('The Torch version is{}.'.format(torch.__version__))
print('The torch version is{}.'.format(torch.__version__))
"""
Check that the course specific tools can be imported
"""
import dtuimldmtools
print('The dtuimldmtools package {}.'.format(dtuimldmtools))
"""
Check that pandas can be imported (use in ex1)
"""
import pandas
print('The panda package {}.'.format(pandas.__version__))
print('------------------------------------------------------------------')
......@@ -82,6 +82,8 @@ plt.title("Iris regression problem")
plt.plot(X_r[:, i], y_r, "o")
plt.xlabel(attributeNames_r[i])
plt.ylabel(targetName_r)
plt.show()
# Consider if you see a relationship between the predictor variable on the
# x-axis (the variable from X) and the target variable on the y-axis (the
# variable y). Could you draw a straight line through the data points for
......@@ -89,3 +91,4 @@ plt.ylabel(targetName_r)
# Note that, when i is 3, 4, or 5, the x-axis is based on a binary
# variable, in which case a scatter plot is not as such the best option for
# visulizing the information.
## exercise 1.5.5
import importlib_resources
import matplotlib.pyplot as plt
import numpy as np
......@@ -8,11 +9,12 @@ import pandas as pd
# We start by defining the path to the file that we're we need to load.
# Upon inspection, we saw that the messy_data.data was infact a file in the
# format of a CSV-file with a ".data" extention instead.
file_path = "../data/messy_data/messy_data.data"
filename = importlib_resources.files("dtuimldmtools").joinpath("data/messy_data/messy_data.data")
# First of we simply read the file in using readtable, however, we need to
# tell the function that the file is tab-seperated. We also need to specify
# that the header is in the second row:
messy_data = pd.read_csv(file_path, sep="\t", header=1)
messy_data = pd.read_csv(filename, sep="\t", header=1)
# We also need to remove the added header line in the .data file which seems
# to have included a shortend form the variables (check messy_data.head()):
messy_data = messy_data.drop(messy_data.index[0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment