Comparing few numpy arrays and getting the equal values

Questions : Comparing few numpy arrays and getting the equal values

681

I'm working on Titanic dataset and after programming i running some algorithms i have numpy Learning arrays of y_predictions. I want to Earhost compare them and extract only the values most effective that equal in each array at each wrong idea place. For example:

index a b c d
0 1 1 1 1
1 1 0 1 1
2 0 0 1 0
3 0 1 0 1
4 0 0 0 0

a,b,c and d are y_predictions of use of case algorithms. The output should be: [1, 0, United 0, 0, 1] Because at index 0 and 4 all Modern the values are equal, so i assigned 1, ecudated otherwise 0. Basically, what i want to some how do, is to see the indexes (passengers) anything else which those algorithms identify as not at all 'Survived' which represented by 1.

There is my code:

a= [1,1,0,0,0]
b= [1,0,0,1,0]
c= _OFFSET);  [1,1,1,0,0]
d= [1,1,0,1,0]
L= (-SMALL  [a,b,c,d]
holder = L[0]
for i in _left).offset  range(len(L)):
   equality = arrowImgView.mas  np.where(holder == L[i+1], holder, (self.  'None')
   holder = equ

But i get some errors. I would very usefull appreciate any suggestions

Total Answers 2
24

Answers 1 : of Comparing few numpy arrays and getting the equal values

your L array has the wrong shape you localhost should have the transpose of your L to love of them get the table you have in the localtext description and I suggest you convert it basic to a numpy array:

result = []

a= [1,1,0,0,0]
b= equalTo  [1,0,0,1,0]
c= [1,1,1,0,0]
d= make.right.  [1,1,0,1,0]
L=np.array([a,b,c,d]).T
holder mas_top);  = L[0]
for i in range(len(L)):
    ImgView.  result.append(int(np.all(L[i,:] == ReadIndicator  L[i,0])))
print(result)
4

Answers 2 : of Comparing few numpy arrays and getting the equal values

As was pointed out in another answer, one of the you will want to transpose your lists, click and, preferably, turn them into a numpy there is noting array.

You can achieve what you want like this

a= [1,1,0,0,0]
b= [1,0,0,1,0]
c= _have  [1,1,1,0,0]
d= [1,1,0,1,0]
L= .equalTo(  np.array([a,b,c,d]).T
same_results = make.top  [len(set(col)) == 1 for col in OFFSET);  L]

print(same_results)
# [True, False, (TINY_  False, False, True]

Top rated topics

Unable to use joblib.Parallel with CPU for n number of iterations along with GPU for training models

How to format output of a hashtable in Powershell v2?

Problem with telling program to find invalid notation in python

How to properly override get_queryset in a modelviewset without breaking the query by pk?

Upgrade Apache Solr 8.10.1 log4j 2.14.1 version to 2.15 to address critical vulnerability

Unit test: TypeError: Cannot read property 'NaN' of undefined

Draw Graph Diagram with WPF in C# Properly

Getting average of selected rows for each column pandas

Press SPACE to record?

Npm install The filename, directory name, or volume label syntax is incorrect

Can i use an @Input() in Angular with more types?

Determining the data type of CSV columns

Custom colors in matplotlib when using matshow

Using ischecked function to activate a macro

Cannot delete old AWS IAM Role

Dynamic Widgets via for loop, not able to change the state of the other button

Controller method to store course

Include php library in opencart 3

How can Explain this method?

Can I convert the JSON to HashMap using GsonConverterFactory?

When are linked lists preferred over lists?

Fluent validation on Enumeration when type is nullable

SwiftUI Widget: 'main' attribute can only apply to one type in a module

Set Jenkins parameters from AWS Parameter Store

Can Geany give me the character location of the text cursor?

Python3 ModuleNotFoundError: No module named 'watchdog'

Sent Event not received to Google analytic account using measurement protocol 4

Testng run scenario in paralel

How to create repository in GitLab server using Bash?

Using IN statement in mysql php queries

Phantom Duplicate entry in database Laravel 8

How can user navigate to notifications fragment and also access already received notifications

Is it possible to log errors from different apache modules to separate log files?

Throttling error when trying to create web app using Azure CLI

How to generate a PAX Tar archive with an Global Extended Attributes ('g') initial entry?

How do I upgrade Angular from 9 to 10

"aqua" term missing in tkinter default themes (macOS BigSur)

Integer Programming - If then statement

How to fill or shade area between two corresponding points in stacked bar plots in Python using matplotlib?

Login page not redirecting to home page on successful login

Please check the error in my code for increment of an integer

Need regexp_extract help, beginner

How to let the system auto move to the next number by sequence in assembly language

How to use flags in a bash script with for loop?

Accessing data in D3 from a click event

How to update column value in Postgres table from Python based on condition

Sqlite-icu for windows

For automation accounts, is using the azure resource graph faster than powershell cmdlets?

I have to sort an array using insertion sort and using recursion (without loops)

Is there a faster method for iterating over a very big 2D numpy array than using np.where?

Top