How to Create a Vector or Matrix in Python?

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

In [1]:
## How to Create & Transpose a Vector or Matrix
def Kickstarter_Example_1():
    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("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("Original Matrix: \n", matrix)
    # Transpose matrix
    M = matrix.T
    print("Transpose Matrix: \n", M)

**************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

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

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.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

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.

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.

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

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

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.