How to Create a Vector or Matrix in Python?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

How to Create a Vector or Matrix in Python?

How to Create a Vector or Matrix in Python?

This recipe helps you Create a Vector or Matrix in Python

0
This python source code does the following : 1. Creates numpy vector and matrix 2. Applies transpose function on the vector and the matrix
In [1]:
## How to Create & Transpose a Vector or Matrix
def Kickstarter_Example_1():
    print()
    print(format('How to Create/Transpose a Vector and/or Matrix', '*^75'))

    # Load library
    import numpy as np

    # Create vector
    vector = np.array([1, 2, 3, 4, 5, 6])
    print()
    print("Original Vector: \n", vector)
    # Tranpose vector
    V = vector.T
    print("Transpose Vector: \n", V)

    # Create matrix
    matrix = np.array([[1, 2, 3],
                   [4, 5, 6],
                   [7, 8, 9]])
    print()
    print("Original Matrix: \n", matrix)
    # Transpose matrix
    M = matrix.T
    print("Transpose Matrix: \n", M)

Kickstarter_Example_1()
**************How to Create/Transpose a Vector and/or Matrix***************

Original Vector:
 [1 2 3 4 5 6]
Transpose Vector:
 [1 2 3 4 5 6]

Original Matrix:
 [[1 2 3]
 [4 5 6]
 [7 8 9]]
Transpose Matrix:
 [[1 4 7]
 [2 5 8]
 [3 6 9]]

Relevant Projects

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.