[PYTHON] How to split machine learning training data into objective variables and others in Pandas

Read data (assuming CSV file)

import numpy as np
import pandas as pd

train = pd.read_csv('train.csv')

Divide the training data into the objective variable (target) and others

#Delete objective variable
train_x = train.drop("target",axis=1)
#Get only the objective variable
train_y = train["target"]

Recommended Posts

How to split machine learning training data into objective variables and others in Pandas
How to collect machine learning data
How to create explanatory variables and objective functions
Machine learning Training data division and learning / prediction / verification
The first step to log analysis (how to format and put log data in Pandas)
How to adapt multiple machine learning libraries in one shot
Pre-processing in machine learning 3 Missing values, outliers, and imbalanced data
How to get an overview of your data in Pandas
How to create dataframes and mess with elements in pandas
Data science companion in python, how to specify elements in pandas
How to build Anaconda virtual environment used in Azure Machine Learning and link with Jupyter
How to interactively draw a machine learning pipeline with scikit-learn and save it in HTML
How to write soberly in pandas
Classification and regression in machine learning
<Pandas> How to handle time series data in a pivot table
Machine learning in Delemas (data acquisition)
Pandas Cleansing Labeled Training Data Split
Preprocessing in machine learning 2 Data acquisition
People memorize learned knowledge in the brain, how to memorize learned knowledge in machine learning
Preprocessing in machine learning 4 Data conversion
How to make a face image data set used in machine learning (3: Face image generation from candidate images Part 1)
Coursera Machine Learning Challenges in Python: ex6 (How to Adjust SVM Parameters)
How to get a specific column name and index name in pandas DataFrame
Python: Preprocessing in machine learning: Handling of missing, outlier, and imbalanced data
How to split and save a DataFrame
Introduction to Machine Learning: How Models Work
scikit-learn How to use summary (machine learning)
How to access environment variables in Python
How to dynamically define variables in Python
Python: Preprocessing in machine learning: Data acquisition
How to reassign index in pandas dataframe
How to enjoy Coursera / Machine Learning (Week 10)
Python: Preprocessing in machine learning: Data conversion
How to read CSV files in Pandas
Preprocessing in machine learning 1 Data analysis process
How to use is and == in Python
How to use pandas Timestamp and date_range
How to create a face image data set used in machine learning (1: Acquire candidate images using WebAPI service)
[Python] How to name table data and output it in csv (to_csv method)
I'm addicted to the difference in how Flask and Django receive JSON data
I tried to process and transform the image and expand the data for machine learning
[Pandas] How to check duplicates and delete duplicates in a table (equivalent to deleting duplicates in Excel)
Python learning notes for machine learning with Chainer Chapters 11 and 12 Introduction to Pandas Matplotlib
How to generate permutations in Python and C ++
Python variables and data types learned in chemoinformatics
[Python] How to read data from CIFAR-10 and CIFAR-100
How to create data to put in CNN (Chainer)
How to read time series data in PyTorch
Data cleaning How to handle missing and outliers
How to write async and await in Vue.js
Add totals to rows and columns in pandas
[For beginners] Introduction to vectorization in machine learning
How to plot autocorrelation and partial autocorrelation in python
How to make a face image data set used in machine learning (2: Frame analysis of video to obtain candidate images)
How to apply markers only to specific data in matplotlib
How to define Decorator and Decomaker in one function
How to scrape horse racing data using pandas read_html
How to convert horizontally held data to vertically held data with pandas
[Python] How to expand variables in a character string
How to access with cache when reading_json in pandas
How to extract null values and non-null values with pandas