Coder Social home page Coder Social logo

jetforme / linearregression Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaylai/linearregression

0.0 2.0 0.0 72 KB

Code to automate performing a multiple linear regression on rock samples to calculate mineral modal abundances given chemical data on bulk, glass, and constituent minerals

License: GNU General Public License v3.0

Python 100.00%

linearregression's Introduction

LinearRegression_excel.py

WHAT IS LINEARREGRESSION_EXCEL.PY?
This is a script to run a least squares multiple linear regresion. It was developed for use in geologic samples in order to model the generation of a daughter rock from a parent magma + crystals via fractional crystallization. The test.xlsx file is laid out for this purpose.

THE TEST.XLSX FILE
SM = "Starting Material". Put the composition of the parent rock here.
All other columns = Compositions measured in the daughter rock (plus compositions of crystals found in the parent rock, if applicable)

OUTPUTS OF THE SCRIPT
The script performs an OLS Regression using pandas and statsmodels.api. See the statsmodels documentation for specific detailed explanations of the output. For the geologic example, the outputs of interest are the coefficients and standard errors. 

Coefficiens (coef) represent phase proportions of each phase that, when added together, make up the components of the parent rock. For example, a coef value of 0.85 for Glass indicates that the daughter liquid is a 85% residual liquid from a parent magma.

Standard Errors (std) tell you how good of a job the script did at finding the correct phase proportions (coefficients). You want this number to be small. A smaller std means a more robust model.

INSTALLATION AND USE
To run this script requires some dependencies:
	1. Python 2.7
	2. pandas - use > sudo easy_install pandas
	3. statsmodels.api - use > sudo easy_install -U statsmodels
	4. xlrd - use > sudo easy_install xlrd

KNOWN ISSUES
Do not use spaces in header row of test.xlsx file, or it will throw an error.

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.