Giter Site home page Giter Site logo

cs440's Introduction

Dataset: from www.ncei.noaa.gov
Order ID: 1520589
Email: [email protected]

Order ID: 1520617
Email: [email protected]

Order ID: 1520669
Email: [email protected]

Order ID: 1520741
Email: [email protected]

Link: github

Requirement:

  • Python 3.4 or newer
  • Matplotlib 2.2.3
  • numpy 1.15.1

Important file:

  • Main.py: main function
  • StatFunction.py: function related to stat
  • Data.py: read data file
  • Piecewise.py: piecewise interpolation
  • Projection.py: do projection
  • LinearSystem.py: solve linear system of equation
  • 1520741.csv: Raw data file

Setup: In python3 interactive shell

import Data
import Projection
import Piecewise
import LinearSystem
import StatFunction

To get data

# get whole data
	(index, temp) = Data.getMin(startYear, startMonth, startDay, endYear, endMonth, endDate)
# get random data
	(index, temp) = Data.getMinRandom(startYear, startMonth, startDay, endYear, endMonth, endDate, numberOfPoint)
# get every k-th point
	(index, temp) = Data.getMin(startYear, startMonth, startDay, endYear, endMonth, endDate, k)

To run interpolation

# best fit polynomial
func = Projection.degreePolynomial(index, temp, degree)
f = lambda x: numpy.polyval(func)
# linear spline
(func, interval) = Piecewise.LinearSpline(index, temp, degree)
f = lambda x: piecewise.cal(interval, func, x)
# quadratic spline
(func, interval) = Piecewise.QuadraticSpline(index, temp, degree)
f = lambda x: Piecewise.cal(interval, func, x)
# cubic spline
(func, interval) = Piecewise.CubicSpline1(index, temp, degree)
f = lambda x: piecewise.cal(interval, func, x)

To visualize the interpolation:

(wholeIndex, wholeTemp) = Data.getMin(year, 1, 1, year+1, 1, 1)
Projection.graphProjection(wholeIndex, wholeTemp, f)

Other useful function

# To predict temperature on a date
# date = number of days from the startYear-startMonth-startDay
f(date)
# To calculate the mean of sum square error
Stat.sumOfSquareError(wholeTemp, list(map(f, wholeIndex)))

cs440's People

Contributors

panaka13 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.