citrine informatics€¦ · citrine informatics $ python (invokes the python intrepreter) $ conda...

18
Citrine Informatics The data analytics platform for the physical world Chris Borg 19 March 2018 Python Citrination Client

Upload: others

Post on 28-May-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Citrine InformaticsThe data analytics platform for the physical world

Chris Borg 19 March 2018

Python Citrination Client

Page 2: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

conda.io/miniconda.html

Install Anaconda (miniconda)

terminal (osx)

$ bash Miniconda3-latest-MacOSX-x86_64.sh

powershell (windows)

Miniconda3-latest-Windows-x86_64.exe

Page 3: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Set env variables (windows)system > advanced system settings > Environment variablesedit > PATH C:\ProgramData\miniconda3; C:\ProgramData\miniconda3\Scripts

Page 4: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Pipenv docs.pipenv.org

The officially recommended Python packaging tool from Python.org

Benefits of virtual environments:

- Easily isolate project requirements- Quickly re-create environment anywhere

Page 5: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

$ python (invokes the Python intrepreter)$ conda (returns Anaconda help info)$ pip (allows for easy_install of Python packages)

$ pip install pypif$ pip install citrination_client

Pip install Citrine python packages

Page 6: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

quick text editing

terminal (osx / linux)

$ vim

powershell (windows)

> New-Item test.txt> notepad.exe test.txt

Page 7: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Store your API key as an env variableterminal (osx / linux)

$ vim ~/.bashrc$ vim ~/.bash_profile>> export CITRINATION_API_KEY=“ABC123”

powershell (windows)

> Get-ChildItem Env: > [Environment]::SetEnvironmentVariable(”CITRINATION_API_KEY", ”ABC123")

Page 8: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Create pif https://github.com/CitrineInformatics/pypif

write pif to file:

outfile = “MgO2.json”

pif.dump(chemical_system, open(outfile, "w"))

Page 9: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Upload pif

$ python

>>> from citrination_client import CitrinationClient

>>> client = CitrinationClient(environ['CITRINATION_API_KEY'], 'https://citrination.com')

>>> client.create_data_set()

>>> client.upload([dataset_number], outfile)

Page 10: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Query for pif$ python

>>> from citrination_client import CitrinationClient

>>> client = CitrinationClient(environ['CITRINATION_API_KEY'], 'https://citrination.com')

>>> query_result = client.search(query)

>>> for hit in query_result:print pif.dumps(query_reulst.hit.extracted, indent=2)

Page 11: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

PyCC query structurePifSystemReturningQuery(

query = DataQuery(

dataset = DataSetQuery(),system = PifSystemQuery(

chemical_formula = ChemicalFieldQuery(),properties = PropertyQuery(

name = FieldQuery()value = FieldQuery())))

ß Defines what query should return

ß filter on dataset

ß filter for specific records

ß Define which properties to extract

Page 12: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

client.dataset_search()

dataset_query = DatasetQuery(owner=[Filter(equal='Chris Borg')])

data_query = DataQuery(dataset=dataset_query)

dataset_returning_query = DatasetReturningQuery(query=data_query)

client.dataset_search(dataset_returning_query)

Page 13: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

client.dataset_search()

Returns DatasetSearchHit object

Page 14: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

client.search()

dataset_query = DatasetQuery(id=[Filter(equal=‘150560’)])

data_query = DataQuery(dataset=dataset_query)

pif_query = PifSystemReturningQuery(query=data_query)

client.search(pif_query)

Page 15: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

client.search()

Returns PifSearchHit object

Page 16: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Accessing the learn-citrination repository

git clone [email protected]:CitrineInformatics/learn-citrination.git

Page 17: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

1. Generate valid training dataset (density.csv, better_density.csv)

2. Create a data view (citrination.com/data_views/27)

3. Test prediction endpoint.

4. Define design space.

5. Batch predictions.

Page 18: Citrine Informatics€¦ · Citrine Informatics $ python (invokes the Python intrepreter) $ conda (returns Anaconda help info) $ pip (allows for easy_install of Python packages) $

Citrine Informatics

Citrine InformaticsThe data analytics platform for the physical world

Thank you