Code Monkey home page Code Monkey logo

machlearn-from-scratch's Introduction

极客时间《零基础实战机器学习》课程代码

《零基础实战机器学习》 是极客时间的一门关于机器学习的入门课,本项目的代码是从黄佳老师的代码 fork 而来,并进行了整理。

环境配置

按照 为学习数学配置软件环境 的思路,首先需要安装 Pythone 环境:

brew install python pipenv jupyterlab

通过如下命令来配置环境:

git clone https://github.com/mengbo/machlearn-from-scratch.git
cd machlearn-from-scratch

pipenv --python 3
pipenv install

# pipenv install ipykernel
pipenv run python3 -m ipykernel install --user --name machlearn

# pipenv install numpy pandas matplotlib
	
# pipenv install plotly nbformat
jupyter labextension install jupyterlab-plotly

# pipenv install seaborn

# pipenv install scikit-learn xgboost

# pipenv install opencv-python

# pipenv install tensorflow keras pydot
brew install graphviz

# pipenv install lifelines

# pipenv install flask

通过如下命令运行 JupyterLab,Kernel 选择 machlearn:

jupyter lab

对于测试数据集 Flowers Recognition 已经拷贝到项目目录下的 input/flowers-recognition 目录中。

细节问题

matplotlib.pyplot 中文问题

可以通过增加程序代码的方式解决:

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['FangSong']
plt.rcParams['axes.unicode_minus']=False

也可以通过修改配置文件解决:

echo "font.sans-serif: FangSong" > ~/.matplotlib/matplotlibrc
echo "axes.unicode_minus: False" >> ~/.matplotlib/matplotlibrc

TensorFlow 错误提示

由于没有优化编译,会产生一些错误提示,完全可以忽略,也可以通过设置如下环境变量解决:

export TF_CPP_MIN_LOG_LEVEL=2

也可以直接在代码中设置:

import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

JupyterLab 下 SVG 图片显示不全

TensorFlow 中的 model_to_dot 产生的 SVG 图片在 JupyterLab 下面显示不全,虽然可以通过调整 CSS 等方法解决,但最简单的办法是修改图片的 DPI 值,例如如下代码:

SVG(model_to_dot(cnn, show_shapes=True, dpi=65).create(prog='dot', format='svg'))

逻辑回归的 max_iter 参数值

sklearn.linear_model.LogisticRegressionmax_iter 参数设置的比较小时,损失函数没有收敛,会出现警告。对于模型的训练和预测效果都已经不错的情况,不需要再增加 max_iter 值,一切以预测效果为基准。

建议修改参数为:LogisticRegression(solver='lbfgs', max_iter=1000)

思维导图

思维导图

machlearn-from-scratch's People

Contributors

huangjia2019 avatar mengbo 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.