Build an interactive environment for machine learning in Python

A memo when building an Octave-like interaction environment with Python. First, install Miniconda (Anaconda is also acceptable). This makes installation explosively easy. After installation, you will be able to use a command called conda that can create a virtual environment, so use this to create an interactive environment.

conda create -n my_env ipython numpy matplotlib scipy scikit-learn cython

When you're done, do ʻactivate my_env` to enable the environment and start the interactive console with ipython. That's it.

The processing flow that is likely to be used is described below.

import numpy as np
import matplotlib.pyplot as plt

#Read training data from csv file(The first line is the header assumption)
D = np.genfromtxt("training_data.csv", delimiter=",", skip_header=1) 

#Cut the data into vectors
y = D[:,0] #Cut out the data in the 0th column(0 here/Suppose that the classification result of 1 is included)
x1 = D[:,1] #Cut out the data in the first column
x2 = D[:,2] #Cut out the data in the second column

#Function to normalize vector(Average 0, standard deviation 1)
def regz(vector):
    return (vector - np.average(vector)) / np.std(vector)

x1_s = regz(x1)
x2_s = regz(x2)

plt.scatter(x1_s[y==1], x2_s[y==1], c="red") # y==Plot 1 minute of data
plt.scatter(x1_s[y==0], x2_s[y==0], c="blue") # y==Plot 0 minutes of data
plt.show()

Recommended Posts

Build an interactive environment for machine learning in Python
Build an environment for machine learning using Python on MacOSX
Build an environment for Blender built-in Python
An introduction to Python for machine learning
Build AI / machine learning environment with Python
I tried to build an environment for machine learning with Python (Mac OS X)
How about Anaconda for building a machine learning environment in Python?
Build a Python machine learning environment with a container
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
Build a machine learning environment
Build a machine learning Python environment on Mac OS
Build a machine learning application development environment with Python
Memo for building a machine learning environment using Python
<For beginners> python library <For machine learning>
Python: Preprocessing in Machine Learning: Overview
Rebuilding an environment for machine learning with Miniconda (Windows version)
Build a PyData environment for a machine learning study session (January 2017)
Python & Machine Learning Study Memo: Environment Preparation
Method to build Python environment in Xcode 6
Amplify images for machine learning with python
Building a Windows 7 environment for getting started with machine learning with Python
[python] Frequently used techniques in machine learning
An introduction to OpenCV for machine learning
Why Python is chosen for machine learning
Python: Preprocessing in machine learning: Data acquisition
[Shakyo] Encounter with Python for machine learning
Build and try an OpenCV & Python environment in minutes using Docker
[Python] When an amateur starts machine learning
[Python] Web application design for machine learning
Python and machine learning environment construction (macOS)
[Python] Saving learning results (models) in machine learning
Python: Preprocessing in machine learning: Data conversion
Learn machine learning anytime, anywhere in an on-demand Jupyter Notebook environment
Creating a development environment for machine learning
Quickly build a python environment for deep learning and data science (Windows)
An introduction to machine learning for bot developers
Building an environment that uses Python in Eclipse
Building an environment for executing Python scripts (for mac)
Building an Anaconda environment for Python with pyenv
Upgrade the Azure Machine Learning SDK for Python
Install the python package in an offline environment
[Python] Collect images with Icrawler for machine learning [1000 images]
Get a glimpse of machine learning in Python
[Implementation for learning] Implement Stratified Sampling in Python (1)
[For beginners] Introduction to vectorization in machine learning
virtual environment in python
Development environment in Python
Python environment for projects
How to build an environment for using multiple versions of Python on Mac
Image collection Python script for creating datasets for machine learning
Tool MALSS (application) that supports machine learning in Python
Coursera Machine Learning Challenges in Python: ex2 (Logistic Regression)
Build a python environment for each directory with pyenv-virtualenv
Python learning memo for machine learning by Chainer from Chapter 2
Python learning memo for machine learning by Chainer Chapters 1 and 2
Tool MALSS (basic) that supports machine learning in Python
[Linux] WSL2 Build an environment for laravel7 with Ubuntu 20.04
Building an environment for natural language processing with Python
Preparing to start "Python machine learning programming" (for macOS)
[Python] I made a classifier for irises [Machine learning]