Machine learning Experiment 1 — Linear regression Documentation

Created by Deline in 2020/11/16

Directory:

[TOC]

Introduction to the

  • This document is to lab1 directory under the unary linear regression and multiple linear regression code introduction, you will understand lab1 directory structure, as well as the program to run the method.

Runtime environment

  • Operating system: Ubuntu20.04 LST

  • Operating software: Pycharm

  • Interpreter: python3.8.2

  • Py library

import numpy as np							# Open source numerical computing extensions. This tool can be used to store and process large matrices
import pandas as pd							# Pandas incorporates a large number of libraries and some standard data models to provide the tools needed to efficiently manipulate large data sets
import matplotlib.pyplot as plt				# Matplotlib is a 2D drawing library for Python
Copy the code

File directory

. ├ ─ ─ data │ ├ ─ ─ ex1data1. TXT │ └ ─ ─ ex1data2. TXT ├ ─ ─ figOne │ ├ ─ ─ fig1. PNG │ ├ ─ ─ fig2. PNG │ └ ─ ─ fig3. PNG ├ ─ ─ figTwo │ ├ ─ ─ fig0. PNG │ ├ ─ ─ fig10. PNG │ ├ ─ ─ fig11. PNG │ ├ ─ ─ fig12. PNG │ ├ ─ ─ fig13. PNG │ ├ ─ ─ fig14. PNG │ ├ ─ ─ fig15. PNG │ ├ ─ ─ Fig16. PNG │ ├ ─ ─ fig17. PNG │ ├ ─ ─ fig18. PNG │ ├ ─ ─ fig19. PNG │ ├ ─ ─ fig1. PNG │ ├ ─ ─ fig20. PNG │ ├ ─ ─ fig21. PNG │ ├ ─ ─ fig2. PNG │ ├ ─ ─ fig3. PNG │ ├ ─ ─ fig4. PNG │ ├ ─ ─ fig5. PNG │ ├ ─ ─ fig6. PNG │ ├ ─ ─ fig7. PNG │ ├ ─ ─ fig8. PNG │ └ ─ ─ fig9. PNG ├ ─ ─ ├── unitarylinearreg. py 3 directories, 30 filesCopy the code
  • data: Tests the data set
  • UnitarylinearReg.py: unary linear regression program
  • figOne: unary linear regression program image save directory
  • MultipleLinearReg.py: multiple linear regression program
  • figTwo: Multiple linear regression program image save directory

How does it work?

  • Type the command pair data setex1data1Perform linear regression fitting and prediction:
$ python ./UnitarylinearReg.py 
Copy the code
  • Type the command pair data setex1data2Perform linear regression fitting and prediction:
$ python ./MultipleLinearReg.py
Copy the code