-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all lecture notebooks and slides.
- Loading branch information
Shyue Ping Ong
committed
Oct 4, 2023
1 parent
313914f
commit 941c9a4
Showing
10 changed files
with
536 additions
and
5,190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 25 additions & 25 deletions
50
lectures/notebooks/Lecture 04 - Linear Methods for Classification.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
146 changes: 60 additions & 86 deletions
146
lectures/notebooks/Lecture 05 - Unsupervised learning.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
3,930 changes: 111 additions & 3,819 deletions
3,930
lectures/notebooks/Lecture 09 - Neural Networks.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import numpy as np | ||
import pandas as pd | ||
from pymatgen.core import Composition | ||
binaries = pd.read_csv('binary_band_gap.csv') | ||
# We create a column holding the Composition object. | ||
|
||
binaries = pd.read_csv("binary_band_gap.csv") | ||
# We create a column holding the Composition object. | ||
# Note the use of list comprehension in Python. | ||
binaries['composition'] = [Composition(c) for c in binaries['Formula']] | ||
electronegs = [[el.X for el in c] for c in binaries['composition']] | ||
binaries["composition"] = [Composition(c) for c in binaries["Formula"]] | ||
electronegs = [[el.X for el in c] for c in binaries["composition"]] | ||
# Create the features mean and difference between electronegativities | ||
binaries['mean_X'] = [np.mean(e) for e in electronegs] | ||
binaries['diff_X'] = [max(e) - min(e) for e in electronegs] | ||
binaries["mean_X"] = [np.mean(e) for e in electronegs] | ||
binaries["diff_X"] = [max(e) - min(e) for e in electronegs] | ||
# Label metals (band gap of 0. 1e-5 is used as numerical tolerance) as class 0 | ||
# Insulators are labelled as class 1. | ||
binaries['class'] = [0 if eg < 1e-5 else 1 for eg in binaries['Eg (eV)']]} | ||
binaries["class"] = [0 if eg < 1e-5 else 1 for eg in binaries["Eg (eV)"]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
>>> import numpy as np | ||
>>> x = np.array([[1, 2, 3], | ||
[4, 7, 6], | ||
[9, 4, 2]]) | ||
>>> y = np.array([1.5, 0.5, 3]) | ||
>>> x * x | ||
array([[ 1, 4, 9], | ||
[16, 49, 36], | ||
[81, 16, 4]]) | ||
>>> np.dot(x, x) | ||
array([[36, 28, 21], | ||
[86, 81, 66], | ||
[43, 54, 55]]) | ||
>>> np.linalg.inv(x) | ||
array([[ 0.16949153, -0.13559322, 0.15254237], | ||
[-0.77966102, 0.42372881, -0.10169492], | ||
[ 0.79661017, -0.23728814, 0.01694915]]) | ||
import numpy as np | ||
|
||
x = np.array([[1, 2, 3], [4, 7, 6], [9, 4, 2]]) | ||
y = np.array([1.5, 0.5, 3]) | ||
x * x | ||
# array([[ 1, 4, 9], | ||
# [16, 49, 36], | ||
# [81, 16, 4]]) | ||
np.dot(x, x) | ||
# array([[36, 28, 21], | ||
# [86, 81, 66], | ||
# [43, 54, 55]]) | ||
np.linalg.inv(x) | ||
# array([[ 0.16949153, -0.13559322, 0.15254237], | ||
# [-0.77966102, 0.42372881, -0.10169492], | ||
# [ 0.79661017, -0.23728814, 0.01694915]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
>>> from scipy import stats # Statistics package | ||
>>> dist = stats.norm(0, 1) # Gaussian distribution | ||
>>> dist.cdf(1.96) | ||
0.9750021048517795 | ||
>>> from scipy import constants # Physical constants | ||
>>> constants.e | ||
1.6021766208e-19 | ||
from scipy import stats # Statistics package | ||
|
||
dist = stats.norm(0, 1) # Gaussian distribution | ||
print(dist.cdf(1.96)) | ||
# Result: 0.9750021048517795 | ||
from scipy import constants # Physical constants | ||
|
||
print(constants.e) | ||
# Result: 1.6021766208e-19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters